Forum Moderators: coopster

Message Too Old, No Replies

need help in creating jump menu in php?

         

Mohamed

2:53 pm on Dec 14, 2005 (gmt 0)

10+ Year Member



I have tried to achieve something like this in jump menu.

- Mariah carey
- we belong
- shake
- Tupac
- yow

my code is
$content .="<form id=\"form1\" method=\"post\" action=\"\">
<select name=\"Quick\" onchange=\"MM_jumpMenu('parent',this,0)\">
<option value=\"#\">Select Artist</option>";
$result= $db->sql_query("SELECT distinct(artist), song, id FROM ".$prefix."_lyrics order by artist asc");
if ($db->sql_numrows($result)) {
while($row = $db->sql_fetchrow($result)) {
extract($row);
$artistinfo[$artist][] = $id;
}
foreach($artistinfo as $artist => $songsarr){
$content .="<optgroup label='$artist'>";
foreach ($songsarr as $id) {
$content .="<option value='modules.php?name=$module_name&amp;file=song&amp;c_id=$id'>$song</option>";
}
}
}
$content .="</select></form>";

the code is working like this
- Mariah carey
- 1
- 20
- Tupac
- 30

but I don't want it like that. what I want is to get song name instead of song id and print song name as sub-category of the artist.
so any help?

coopster

6:36 pm on Dec 14, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You don't seem to be adding $song to your $artistinfo array anywhere here at all ...? The option list should be exactly the same for each item as the code exists here...

Mohamed

9:22 pm on Dec 14, 2005 (gmt 0)

10+ Year Member



thanks coopster, you are right. I forgotten to add song and I realized it after I post the post!