I am very new to the Mysql/php environment so would appreciate guidance here please.
1) I have a php program that uses a Form to enter data into a MySQL table. This is working OK when data is entered into the fields manually.
2) I have a short php script that reads data from another table and creates a drop down list of the data. This is working OK too.
Now I want to substitue the drop down list for the existing input box on the form, and for the user 'selected data' in the php list to be saved in the appropriate field when the form is submitted.
I have pasted the php script just above the form input box which I want to replace.
See code:
<form action="ADD2.php" method="post" style="padding: 5px; height: 550px" class="style13">
<?php
$con = mysql_connect($host,$user,"$pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($db, $con);
$query="SELECT reporter,id FROM swaag_reporters";
/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */
$result = mysql_query ($query);
echo "<select name=swaag_reporters value=''>reporter</option>";
// printing the list box select command
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[id]>$nt[reporter]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
//$nt[1]=$_POST['recorder_by'];
?>
Recorded by: <input type="text" size="30" name="recorded_by" />
In effect I want to save the selected 'reporter' from the drop down list, to be posted where the existing name="recorded_by is being saved by the current form entry.
What do I need to do?
Many thanks for taking time to reply
Stephen