Is the anyone who can hjelp me with this code. I want to get data from a field of my table and show them in a dropdown menu.
Every data I get become a dropdown of one element. I get want to get a dropdown with alle data from this field.
Here is my code:

<?php
(Database connection)
$result2 = mysql_query("SELECT DISTINCT theme FROM  mytable ") 
                    or die(mysql_error());


                while($row2 = mysql_fetch_array( $result2 )) 
                    {
?>
                        <form method="post" action='<?php echo $_SERVER["PHP_SELF"]; ?>'>

                            <select name='themes'">
<?php

                        $arr= array($row2['theme']);

                        foreach($row2 as $value)
                        {
                            echo "<option value='$value'><b>". $value."</b> </option><br> ";

                        }

                    }
?>

Thanks for help
Temax

You can also do something like this

echo "<form method = 'post' action = ''>";
echo "<select name = 'theme'>";
while($row2 = mysql_fetch_object($result2))
{
	echo "<option value = '".$row2->theme."'>".$row2->theme."</option>";
}
echo "</select>";
echo "</form>";
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.