0

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

Edited by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by cossay
0

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>";
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.