I am needing a dropdown menu to pull data from table on a mysql database and then with the selected item, send it to a new table along with the rest of the data from the form.

I have got the dropdown pulling data from the database with the following code:

<?php
$con = mysql_connect($sqlserver,$sqluser,$sqlpassword);
if (!$con)
{
die('Connection to SQL Server failed. Error:   ' . mysql_error());
}
mysql_select_db($sqldb, $con);
$result = mysql_query("SELECT functions FROM functions");
echo "<SELECT id=\'func\' name=\'func\' multiple=\'multiple\'>";
						
						if (mysql_num_rows($result)>0)
						{
								while($row=mysql_fetch_array($result))
							{
								echo "<option value=\'$row[functions]\'>$row[functions]</option>";
							}
						}
						echo "</SELECT>";
						mysql_close($con)
					?>

Which works fine,

however I am totally baffled as to how i get it to send with the form. Is there something im missing here?

Cheers.

Recommended Answers

All 2 Replies

btw sorry for the code scatter there no idea how that happened.

You haven't defined a form! Before you start generating Select and Option statements, you need to define a form (<form action=xxxx, method=post>) where xxxx is the module that will receive the form output (it will default to the same module that creates the form). At the very end, you will want to add a submit button and a closing </form>.

If you aren't familiar with forms, then do a search and read some tutorials.

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.