Forum Moderators: coopster

Message Too Old, No Replies

2 Dim. Array with MySQL result

quick syntax help with 2 dim. array

         

ryan_b83

3:31 am on Oct 7, 2006 (gmt 0)

10+ Year Member



Hello, I am trying to use a 2 dimensional array in a script. For example...


//MAIN FLOW
$counter = 0;
$sql[$counter] = "SELECT * FROM category WHERE parent = 0 ORDER BY parent";
$result[$counter] = mysql_query($sql) or die(display_and_log_error("SQL ERROR: ".__LINE__));
while($myrow[$counter] = mysql_fetch_assoc($result[$counter])){
echo $myrow[$counter][category_name];
...

This two dimensional array wont work? I thought I had the syntax correct, but do 2 dimensional array's not work with mysql result values as one of the dimensions?

Thanks!
Ryan

eelixduppy

4:03 am on Oct 7, 2006 (gmt 0)



Try this:

$result[$counter] = mysql_query($sql[b][$counter][/b]) or die(display_and_log_error("SQL ERROR: ".__LINE__));

Good luck!

ryan_b83

4:11 am on Oct 7, 2006 (gmt 0)

10+ Year Member



Worked Thanks!