hello. I have a drop down menu that pulls from a mysql database. I know its connecting fine and there is actual items in the drop down menu because I echoed them.

However when I look at my drop down box, you cannot see the options! I know the items are there but its simply not visible. HOw can I alter my code so that its visible.

php:

$sql="SELECT title FROM Election";
$result= mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
  $title=$row["title"];
    $options.="<OPTION VALUE=\"$title\">";
     }

}

HTML:

<SELECT NAME="title" style="font-size:11pt; font-family: arial,helvetica,sans-serif; color:#080000">
<OPTION VALUE="0" style="font-size:11pt; font-family: arial,helvetica,sans-serif; color:#080000">View an election

<?=
$options
?>
</SELECT>

Recommended Answers

All 6 Replies

hello. I have a drop down menu that pulls from a mysql database. I know its connecting fine and there is actual items in the drop down menu because I echoed them.

However when I look at my drop down box, you cannot see the options! I know the items are there but its simply not visible. HOw can I alter my code so that its visible.

php:

$sql="SELECT title FROM Election";
$result= mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
  $title=$row["title"];
    $options.="<OPTION VALUE=\"$title\">";
     }

}

HTML:

<SELECT NAME="title" style="font-size:11pt; font-family: arial,helvetica,sans-serif; color:#080000">
<OPTION VALUE="0" style="font-size:11pt; font-family: arial,helvetica,sans-serif; color:#080000">View an election

<?=
$options
?>
</SELECT>

try this:
php:

$sql="SELECT title FROM Election";
$result= mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
  $title=$row["title"];
    $options.="<OPTION VALUE=\"$title\">$title</OPTION>";
     }

}

HTML:

<SELECT NAME="title" style="font-size:11pt; font-family: arial,helvetica,sans-serif; color:#080000">
<OPTION VALUE="0" style="font-size:11pt; font-family: arial,helvetica,sans-serif; color:#080000">View an election

<?
echo $options;
?>
</SELECT>

hope it helps... cheers!!

I have just done something similar. The above looks good to me, but if it doesn't work then I'll post my code up too

:)

I have just done something similar. The above looks good to me, but if it doesn't work then I'll post my code up too

:)

Yeah i should have tested it b4 posting here.. :P
newayz its pretty simple n shud work..:idea:

hope it helps... cheers!!

OMG. thank you very much! It works! This helped a lot. something so minor like this was giving me a headache. lol thanks again!

sorry

OMG. thank you very much! It works! This helped a lot. something so minor like this was giving me a headache. lol thanks again!

well if ur problem is solved then i suggest u mark the thread as solved..
Glad i could help..
cheers!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.