|
Posted by shimmyshack on 06/29/07 03:29
On Jun 29, 2:36 am, up2trouble <lynettesm...@gmail.com> wrote:
> I'm trying to create a dynamic menu with plain text links ... no
> javascript, no css, no dhtml, etc. Ideally, the top level categories
> have sub-menus. I got the top level, but I can't get the sub level.
>
> | Home | Courses | Personal | Admin |
>
> <?PHP
> $result_parent = mysql_query("SELECT * FROM $db_table6 WHERE parent =
> 'Main' AND sublevel2 != '1' ORDER BY sublevel2 ASC ");
> echo " | ";
> while ($row = mysql_fetch_array($result_parent))
> {
> $name = $row['name'];
> $url = $row['url'];
> echo "<A CLASS='nav' HREF='http://lynnesmith.net/$url'ALT='$name'
> TARGET='_top'>$name</A>";
> echo " | ";}
>
> ?>
>
> record parent sublevel2 sublevel3 name url
> 1 Main 0 0 Home index.php
> 2 Main 1 0 Address Book addressbook.php
> 4 Personal 2 1 personal/ab_addperson.php
> 16 Main 2 0 Courses courses/index.php
> 6 Admin 1 1 Edit Blog admin/blogentryedit.php
> 7 Courses 1 0 CITA 110 courses/cita110index.php
> 8 Courses 2 0 CITA 210 courses/cita210index.php
> 10 Admin 2 1 Add Address Book Category admin/ab_category.php
> 11 Courses 3 0 CITA 330 courses/330index.php
> 12 Courses 3 1 Webmaster Tools courses/330tools.php
> 13 Main 1 0 Reading Room news.php
> 14 Main 4 0 Admin admin/index.php
> 17 Main 3 0 Personal personal/index.php
it is a bit hard to know exactly what you are trying to do.
what you need to do is break the problem down into steps:
perhaps start off with an array of all the names and urls you have and
see how to order them so you can get at what you want
then turn those into links,
now obtain the array from the database in the way you need, either
$arrayLinks = array();
while ($row = mysql_fetch_array($result_parent))
{
$arrayLinks[] = array('row'=>$row['name'],'url'=>$row['url']);
}
or
$arrayLinks = array();
while ($row = mysql_fetch_array($result_parent))
{
$arrayLinks[] = array($row['name'],$row['url']);
}
or
$arrName = array();
$arrUrl = array();
while ($row = mysql_fetch_array($result_parent))
{
$arrName[] = $row['name'];
$arrUrl[] = $row['url'];
}
perhaps then you can just see the solution.
Navigation:
[Reply to this message]
|