Jump to content
Larry Ullman's Book Forums

Question About Mysql And Arrays


Recommended Posts

I thought there was a more direct way of doing this. I want to put the results of the query into the array "$itemDivs_array". Do I need to loop through like this?

 

 

 

$q = "SELECT DISTINCT itemDivisionName from luItemTypes";
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));
echo "the number of rows is ".mysqli_num_rows($r)."<br />";


$kount = 0;
while ($row = mysqli_fetch_array ($r, MYSQLI_ASSOC)) {
	echo $row['itemDivisionName'].", ";
	$itemDivs_array[$kount]=$row['itemDivisionName'];
	$kount += 1;
}



mysqli_close($dbc);

 

thank you,

chop

Link to comment
Share on other sites

Thanks. I see what you mean about the counter index. Every once in a while I have flashbacks to my Basic or Pascal days.

Although, wouldn't it be nice to be able to say something like:

 

$shortDescription_array[]= mysqli_fetch_array ($r, MYSQLI_NUM)

 

??

 

chop

Link to comment
Share on other sites

 Share

×
×
  • Create New...