Jump to content

Recommended Posts

Greetings,

I've been hurting my head for the past day or so trying to figure out how to do this. If anyone could give me any sort of advice to head me in the right direction I would appreciate it.

 

I am trying to build a set of navigation links with sublinks from a db. The output I want would be something like:

DogCatBird

PuppyGarfieldTweety

MaxKittenParrot

 

I was thinking the db would something like:

idtitleurlparent

For the sublinks, and:

id title url

For the categories.

 

I was considering grabbing the links via a select "where parent = ##". The place I am stuck at, is figuring out how to actually use this in order to properly output the links. My first thought was perhaps use nested for()'s. An array of an array of an array or something. Perhaps:

$links[$a][$b]['title'] = 'Puppy';

$a would be the id of the header "Dogs", and $b would be a sort for the row containing "Puppy".

 

for($a = 0; $a <= mysql_num_rows($category_query); $a++)
{
echo $category['title'];
// And assorted other html's
  for($b = 0; $b <= mysql_num_rows($sublinks_query); $b++)
  {
echo $category[$a][$b]['title'];
// etc.
  }
}

This seems very, messy, to me. Perhaps its not, what do I know. Is this the way I should be going, or is there a simpler easier, more efficient way I don't know about? Thanks for any input.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.