Re: Dynamic Multi Level Drop Down Menu in PHP/MYSQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Joe,

I am sorry I am not a PHP expert. I don't understand well about this.

Could you provide me a complete code?


Regards,

Vichea

On Tue, Jun 1, 2010 at 11:33 PM, Joe Forsythe
<jforsythe@xxxxxxxxxxxxxxxxxx>wrote:

>
>
> At a glance it looks like you have everything you need in the
> database. Which is good -- I was expecting an issue there.
>
> In this case, I'd probably do a nested loop -- you need to be able to
> loop through the submenu items. That also means limiting results at
> the different levels of loop to the current level ONLY.
>
> Probably start with something like this:
> $sql = 'SELECT * FROM menu WHERE parentid = PARENT_ID_GOES_HERE';
>
> That way, when you loop through your results, all you're getting are
> the top level results for the child you're on. As you hit each
> result, you'll need to pop the database to check for children.
>
> Personally, I'd move away from mysql_fetch_array -- it can be tough
> to manage, and gives you a lump set of info. My preference in a case
> like this would generally be a combination of a FOR loop and
> mysql_result.
>
> Something like this seems appropriate:
> for ($i = 0; $i < mysql_num_rows($rows); $i++)
>
> Then, for each id that you roll across, you call your nested loop
> function with the SQL statement.
>
> This will also give you the flexibility for if you have a lot of
> navigation, and a lot of children <ul>'s.
>
> If you have any problems with the new code that you write, hit us up.
> --
> Joe
>
>
> On Jun 1, 2010, at 11:08 AM, Sovichea SOU wrote:
>
> > $sql = "SELECT * FROM menu";
> > $rows = mysql_query($sql, $con);
> >
> > if(mysql_num_rows($rows > 0)){
> >
> > while($record = mysql_fetch_array($rows)){
> > $title = $record["title"];
> > echo "<li>$title</li>";
> >
> >
> > }
> >
> >
> > }
> >
> > On Tue, Jun 1, 2010 at 10:57 PM, Joe Forsythe
> > <jforsythe@xxxxxxxxxxxxxxxxxx <jforsythe%40mosaiccreative.com>>wrote:
> >
> >>
> >>
> >> What is the PHP code that you're using right now?
> >> --
> >> Joe
> >>
> >>
> >> On Jun 1, 2010, at 10:41 AM, Sovichea SOU wrote:
> >>
> >>> Hello Joe,
> >>>
> >>> Thanks for your fast reply.
> >>>
> >>> I can loop only like this:
> >>>
> >>> <ul>
> >>> <li>Item1</li>
> >>> <li>Item2</li>
> >>> <li>Item2a</li>
> >>> <li>Item2b</li>
> >>> </ul>
> >>>
> >>> It should be look like this with nested list:
> >>>
> >>> <ul>
> >>> <li>Item 1</li>
> >>> <li>Item 2
> >>> <ul>
> >>> <li>Item 2a</li>
> >>> <li>Item 2b</li>
> >>> </ul>
> >>> </li>
> >>> </ul>
> >>>
> >>> This is database:
> >>>
> >>> id - title - link - parentid
> >>> 1 - Item1 - http://www.yahoo.com - 0
> >>> 2 - Item2 - http://www.google.com - 0
> >>> 3 - Item2a - http://www.chhit.com - 2
> >>> 4 - Item2b - http://www.gmail.com - 2
> >>>
> >>> Could you tell me how to write this kind of loop?
> >>>
> >>> Thanks,
> >>>
> >>> Vichea
>
> [Non-text portions of this message have been removed]
>
>  
>   Reply to sender<jforsythe@xxxxxxxxxxxxxxxxxx?subject=Re:+%5Bphp-objects%5D+Dynamic+Multi+Level+Drop+Down+Menu+in+PHP/MYSQL>| Reply
> to group<php-objects@xxxxxxxxxxxxxxx?subject=Re:+%5Bphp-objects%5D+Dynamic+Multi+Level+Drop+Down+Menu+in+PHP/MYSQL>| Reply
> via web post<http://groups.yahoo.com/group/php-objects/post;_ylc=X3oDMTJwNGNtM2tuBF9TAzk3MzU5NzE0BGdycElkAzIwMzE1NjQEZ3Jwc3BJZAMxNzA1MDA2NzY0BG1zZ0lkAzk4NDEEc2VjA2Z0cgRzbGsDcnBseQRzdGltZQMxMjc1NDEwMDAz?act=reply&messageNum=9841>| Start
> a New Topic<http://groups.yahoo.com/group/php-objects/post;_ylc=X3oDMTJlNXJmZDk5BF9TAzk3MzU5NzE0BGdycElkAzIwMzE1NjQEZ3Jwc3BJZAMxNzA1MDA2NzY0BHNlYwNmdHIEc2xrA250cGMEc3RpbWUDMTI3NTQxMDAwMw-->
> Messages in this topic<http://groups.yahoo.com/group/php-objects/message/9824;_ylc=X3oDMTM0NW1vMzQwBF9TAzk3MzU5NzE0BGdycElkAzIwMzE1NjQEZ3Jwc3BJZAMxNzA1MDA2NzY0BG1zZ0lkAzk4NDEEc2VjA2Z0cgRzbGsDdnRwYwRzdGltZQMxMjc1NDEwMDAzBHRwY0lkAzk4MjQ->(
> 14)
>  Recent Activity:
>
>    - New Members<http://groups.yahoo.com/group/php-objects/members;_ylc=X3oDMTJmMWM5czdhBF9TAzk3MzU5NzE0BGdycElkAzIwMzE1NjQEZ3Jwc3BJZAMxNzA1MDA2NzY0BHNlYwN2dGwEc2xrA3ZtYnJzBHN0aW1lAzEyNzU0MTAwMDM-?o=6>
>    14
>
>  Visit Your Group<http://groups.yahoo.com/group/php-objects;_ylc=X3oDMTJlM2NmZmMwBF9TAzk3MzU5NzE0BGdycElkAzIwMzE1NjQEZ3Jwc3BJZAMxNzA1MDA2NzY0BHNlYwN2dGwEc2xrA3ZnaHAEc3RpbWUDMTI3NTQxMDAwMw-->
>  Are you looking for a PHP job?
> Join the PHP Professionals directory Now!
> http://www.phpclasses.org/jobs/
>  MARKETPLACE
>
> Stay on top of your group activity without leaving the page you're on - Get
> the Yahoo! Toolbar now.<http://us.ard.yahoo.com/SIG=15otersb2/M=493064.13983314.14041046.13298430/D=groups/S=1705006764:MKP1/Y=YAHOO/EXP=1275417203/L=65b9dbc0-6d9b-11df-ba4b-5b0b051c5fc0/B=.jfEP2KImnI-/J=1275410003852481/K=_BpRWkL56_Zzet.RG8yxLw/A=6060255/R=0/SIG=1194m4keh/*http://us.toolbar.yahoo.com/?.cpdl=grpj>
>   ------------------------------
>
> Get great advice about dogs and cats. Visit the Dog & Cat Answers Center.<http://us.ard.yahoo.com/SIG=15oekcnjb/M=493064.13814537.14041040.10835568/D=groups/S=1705006764:MKP1/Y=YAHOO/EXP=1275417203/L=65b9dbc0-6d9b-11df-ba4b-5b0b051c5fc0/B=.zfEP2KImnI-/J=1275410003852481/K=_BpRWkL56_Zzet.RG8yxLw/A=6078812/R=0/SIG=114ae4ln1/*http://dogandcatanswers.yahoo.com/>
>   ------------------------------
>
> Hobbies & Activities Zone: Find others who share your passions! Explore new
> interests.<http://us.ard.yahoo.com/SIG=15ovotlt7/M=493064.14012770.13963757.13298430/D=groups/S=1705006764:MKP1/Y=YAHOO/EXP=1275417203/L=65b9dbc0-6d9b-11df-ba4b-5b0b051c5fc0/B=_DfEP2KImnI-/J=1275410003852481/K=_BpRWkL56_Zzet.RG8yxLw/A=6015306/R=0/SIG=11vlkvigg/*http://advision.webevents.yahoo.com/hobbiesandactivitieszone/>
>    [image: Yahoo! Groups]<http://groups.yahoo.com/;_ylc=X3oDMTJkYTJnMHFuBF9TAzk3MzU5NzE0BGdycElkAzIwMzE1NjQEZ3Jwc3BJZAMxNzA1MDA2NzY0BHNlYwNmdHIEc2xrA2dmcARzdGltZQMxMjc1NDEwMDAz>
> Switch to: Text-Only<php-objects-traditional@xxxxxxxxxxxxxxx?subject=Change+Delivery+Format:+Traditional>,
> Daily Digest<php-objects-digest@xxxxxxxxxxxxxxx?subject=Email+Delivery:+Digest>?
> Unsubscribe <php-objects-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>? Terms
> of Use <http://docs.yahoo.com/info/terms/>
>    .
>
> __,_._,__
>


[Non-text portions of this message have been removed]



------------------------------------

Are you looking for a PHP job?
Join the PHP Professionals directory Now!
http://www.phpclasses.org/jobs/
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-objects/join
    (Yahoo! ID required)

<*> To change settings via email:
    php-objects-digest@xxxxxxxxxxxxxxx 
    php-objects-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux