Hi all
I’m trying to store some names from an SQL result into a multi array, but when I try looping through the array, all I get is each letter from sequentially from the last name entered:
[code=php]$petsquery = “SELECT pet_name, pet_breed, pet_desc, pet_gender, user_id_fk FROM pets WHERE user_id_fk=’$session_user_id'”;
$petsqueryresult = mysql_query($petsquery);
while($row = @mysql_fetch_array($petsqueryresult, MYSQL_ASSOC)){
if($row){
$hasPets = true;
}
$numOfPets ++;
$pets[‘names’] = $row[‘pet_name’];
$pets[‘breeds’] = $row[‘pet_breed’];
$pets[‘desc’] = $row[‘pet_desc’];
$pets[‘gender’] = $row[‘pet_gender’];
}
then I try to print out each name:
[code=php]for($i = 0; $i < $numOfPets; $i++){ ?>
Pet Name: <?php echo $pets[‘names’][$i]; ?>
<input type=”checkbox” class=”theCheck” id=”<?php //echo $value ?>” name=”<?php //echo $value ?>” value=”<?php //echo $value ?>”> <?php //echo $value ?><br />
<div class=”petRegBox” id=”<?php echo $names.”Box”; ?>”>
</div>
<?php } ?>
the result looks like this:
Pet Name: S
Pet Name: t
Pet Name: i
so for each pet (3) it’s listing the first 3 lettery from the last pet in the array (Stinky)
I have no idea what’s going on – please help??