I have the code below. The PHP works and displays the results in a drop-down box. What I want to do is, when a person uses the drop-down box and selects a client, it automatically puts the client's 'ID' in the text box in the right column.
Any help would be greatly appreciated.
<table width="100%" cellpadding="3" cellspacing="1" border="0">
<tr>
<td><select value="clients1"><?
// includes
include("connex.php");
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// generate and execute query
$query = "SELECT * FROM clients ORDER BY ID DESC";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// if records present
if (mysql_num_rows($result) > 0)
{
// iterate through resultset
// print article titles
while($row = mysql_fetch_object($result))
{
?>
<option value="<? echo $row->ID; ?>"><? echo $row->name; ?></option>
<?
}
}
// if no records present
// display message
else
{
?>
<b><font face="Tahoma, Verdana, Arial, Helvetica, sans-serif" color="#000000" size="1">no clients currently available</font>
<?
}
// close database connection
mysql_close($connection);
?></select></td>
<td><input size="20" maxlength="150" type="text" name="clients"></td>
</tr>
</table>