Joachim
Tom Wollaston wrote:
I have been trying to write some code for a simple menu system. The idea was that every item on a menu should be tied to anouther to give a menu structure.
To do this I have tried to use the following code. Some of it I have added in to try and understand why its not really working. My first problem is that the function I use seems to omit the first result, even if I make the select compleatly unbounded. My second problem is that I do not seem to be able to figure out how to display the correct part of the array. Currently I have been using print_r which just displays a list. When I try to display what I want it doesn't do anything. I think I may have messed up the function codeing but I cannot see where I have gone wrong and I have been doing it all day (time now 1.02 in the morning). If anybody can help it would be appreciated.
<?php include "includes/constants.php";
$link = @mysql_connect($DB_server, $DB_user, $DB_pwd) or die ("Could not connect"); @mysql_select_db($DB_user) or die ("Could not select database");
$null=getinfo('0');
for ($i=1; $i<=sizeof($null); $i++); { print_r($null); /* print $nul[$i]['name']; $j=$null[$i]['id']; /*$fisrt=getinfo["1"]; for ($k=1; $k<=sizeof($first); $k++); { echo $first[$k]['name']; $l=$first[$k]['id']; $second=getinfo['$m']; for ($m=1; $m<=sizeof($second); $m++); { echo $second[$m]['name']<br>; } }*/ } ?> </td> </td> <td> </td> </tr> </table> </body> </html> <?php function getinfo($pid) { $query = "SELECT name,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