Create two database tables.  One for categories and one for links.  Here are
the fields you want for categories:

- ID
- ParentID
- Title

The ParentID field allows  you to create a hierarchy of categories - one
category and it's sub-categories.  For example:

ID      ParentID        Title
========================
1       0               Home
2       1               Books
3       1               Movies
4       2               Sci-Fi
5       2               Adventure
6       3               Sci-Fi
7       3               Adventure

Will create the following hierarchy:


                                        Home (0)
                                          |
                                -------------------------
                                |                               |
                            Books                           Movies
                                |                               |
                        -------------           -------------
                        |               |               |               |
                   Sci-Fi         Adventure         Sci-Fi
Adventure


Your Links table will have the following fields:

- ID
- ParentID
- Title



Create forms for adding, editing, and deleting categories.
Create forms for adding, editing, and deleting links.

Set up a main page.... the CatID should be 0 at this point.

List categories with ParentID = 0 and have a link to add categories and
links.  

The add category form will store the current CatID as ParentID.

The add link form will operate the same way.

Then it's just an issue of creating a page that lists all of the categories
and links that have the current CatID as the ParentID.  When you list them,
create links for them to the same page that references the ID

<a href='index.php?CatID=<?php echo $Row["ID"];?>'><?php echo
$Row["Title"];?></a>

and just loop through that for all of the result set and you're on your
way...

ok... I'm pretty sure this might be somewhat vague... sorry, I'm trying to
help as much as I can with only a short amount of time at the moment.  Feel
free to ask questions, but try to research this and see how much you can
figure out on your own first =)

-Ed



> -----Original Message-----
> From: Daniel Broome [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 4:08 PM
> To: Lazor, Ed
> Subject: Re: [PHP] Arrays
> 
> 
> I dont know how to explane this.. what I need to do is, I 
> have a menu with
> sub links that are desplayed when the topic is clicked.
> 
> what I need to do is create a script that is easy to edit, at 
> the moment I
> am having to write all the HTML inside the PHP script.. e.g
> $sub="<li>link goes here</li> etc.
> for each topic I have a script.
> 
> What I would like to do is say, if $menu = contact foreach 
> array in topic
> echo "thier $link and $name"
> 
> I think I can do it myself but I need help on what commands I 
> can use and
> what is the best way to use them.
> 
> thanks for helping.
> 
> Dan
> 
> ----- Original Message -----
> From: "Lazor, Ed" <[EMAIL PROTECTED]>
> To: "'Dan'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Tuesday, June 11, 2002 10:45 AM
> Subject: RE: [PHP] Arrays
> 
> 
> > Get the number of items in the array using the count 
> function and then use
> a
> > for statement to loop through them from start to finish.  Here's an
> example:
> >
> >
> > $Total = count($link);
> >
> > for ($i = 0;$i < $Total;$i++)
> > print "<li><a href='".$link[$i]."'>$name</a></li>";
> >
> > Of course, the link names will all be the same, so you'll 
> probably want to
> > store that in the array as well...
> >
> > for ($i = 0;$i < $Total;$i++)
> > print "<li><a
> > href='".$link[$i][url]."'>".$link[$i][name]."</a></li>";
> >
> >
> > -----Original Message-----
> > From: Dan [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 3:01 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] Arrays
> >
> >
> > I'm trying to get my head around arrays and how to munipulate them.
> >
> > what I need to do is add html around the arrays eg.
> > <li><a href='".$link(0)."'>".$name."</a></li>;
> >
> > I have my head around that but I the number of lines the I 
> need to create
> is
> > going to change so I need the script to repeat untill all 
> the arrays are
> > used.
> >
> > --
> > -----------------------------------------
> > Daniel Broome, siliconBLUE Ltd, Web Author,
> > http://siliconblue.com
> > Mob: 64-21-178-5120
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> **************************************************************
> **************
> > This message is intended for the sole use of the individual 
> and entity to
> > whom it is addressed, and may contain information that is 
> privileged,
> > confidential and exempt from disclosure under applicable 
> law.  If you are
> > not the intended addressee, nor authorized to receive for 
> the intended
> > addressee, you are hereby notified that you may not use, 
> copy, disclose or
> > distribute to anyone the message or any information contained in the
> > message.  If you have received this message in error, 
> please immediately
> > advise the sender by reply email and delete the message.  
> Thank you very
> > much.
> >
> >
> 
 
****************************************************************************
This message is intended for the sole use of the individual and entity to
whom it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  If you are
not the intended addressee, nor authorized to receive for the intended
addressee, you are hereby notified that you may not use, copy, disclose or
distribute to anyone the message or any information contained in the
message.  If you have received this message in error, please immediately
advise the sender by reply email and delete the message.  Thank you very
much.                                                                       

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to