Same key in array
Posted: Tue Sep 04, 2007 1:59 pm
I am working on returning my results into a three row table. I'll get the number of rows, divide it by 3 and limit the column by $key <= 1/3 of the total rows. Simple enough but when I use the method below, $key is always equal to 0 which kills my whole idea. Is there a better mysql_fetch_* for this use?
Code: Select all
<?php
mysql_connect('localhost','','');
mysql_select_db('test');
echo "<h3>Multiple Row Test</h3>\n";
$query="SELECT people_lname FROM people ORDER BY people_lname";
$result=mysql_query($query) or die (mysql_error());
while($row=mysql_fetch_array($result)){
foreach($row as $key=>$value){
echo $key."<br />\n";
}
}
mysql_close();
?>