I am trying to make a companion to go with my druid but cant figure out what its starting hp would be and what modifiers might be on it later as I level as a druid. Can someone tell me how it works?
Here's what the SRD says about animal companions:
Animal Companion Basics Use the base statistics for a creature of the companion’s kind, but make the following changes.
So in the case of a riding dog, you'd use the creature stats provided in its entry. Talk with your DM whether they'll let you roll its HP using the Hit Dice entry or require you to take the average value listed in parentheses. Take note of any special rules listed for the animal — a riding dog can make trip attacks like wolves, and it gets a bonus to Survival checks when tracking by scent.
As you level up as a druid, your animal companion gets stronger according to the Animal Companion table. Natural armor, Strength/Dexterity scores, and bonus tricks should be fairly straightforward since you're adding a flat value, but bonus Hit Dice is more complex since it affects more things. The descriptions under the table summarize this fairly well, but you can get more specifics from the section for improving monsters. Note that the section about size increases doesn't apply to animal companions.
Remember to apply bonuses for each HD your animal companion gets — that includes more HP and skill points. Creatures get a new feat for every 3 HD they have and an ability score increase for every 4 HD, just like PCs. Since a riding dog already has 2 HD, at druid level 3 it jumps right up to 4 HD, giving it both a feat and an ability score increase.
Also, at higher levels druids get access to new kinds of animals from the list of Alternative Animal Companions. If you go this route, talk with your DM to figure out how your PC can go about acquiring one, but keep in mind that it lowers your effective druid level for determining animal companion bonuses.