|  | Posted by deko on 06/09/06 09:50 
I'm trying to select a few rows:
 $db = mysql_connect('localhost','userID','passwd');
 if ($db)
 {
 $sql = "select cat_ID, cat_name from categories where category_count > 0";
 mysql_select_db('dbName');
 $result = mysql_query($sql);
 $arrayCat =  mysql_fetch_array($result);
 }
 mysql_close;
 
 echo count($arrayCat); //count = 4
 
 foreach ($arrayCat as $cat)
 {
 // this will iterate 4 times
 echo "<br>".$arrayCat["cat_ID"]; // = 1
 echo "<br>".$arrayCat["cat_name"]; // = test
 }
 
 what I don't understand is I get an array count of 4, but if I look in the
 table, I see only 3 rows that meet the select criteria.  Furthermore, why does
 each iteration echo the same thing:
 
 1
 test
 1
 test
 1
 test
 1
 test
 
 Am I using mysql_fetch_array wrong?
 
 Thanks in advance.
  Navigation: [Reply to this message] |