I have made this function which should be quite simple but doesn't seem to
do what it is meant to.
What I want it to do is create an array where there is a numbered key (the
rows of the table) and the colume headings as the second key.
It doesn't seem to work. If I set $pid=0 then I get no results (even though
there are such values in the table), and when $pid=1 I get the results I
expect but they are not sorted in the way I expected.
This means that I cannot then use this data for its end effect which is a
menu system.
Thanks
<?php
function getinfo($pid)
{
$query = "SELECT name,id,parentid FROM ubsc_menu WHERE parentid='$pid' ";
$result = mysql_query ($query) or die ("Query failed");
$row=mysql_fetch_array($result,MYSQL_ASSOC);
$n = 1;
while ($row=mysql_fetch_array($result,MYSQL_ASSOC))
{
foreach ($row as $colname => $value)
{
$array[$n][$colname] = $value;
}
$n++;
}
return $array;
}
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php