I'm a php noob and I have a feeling that there is a simple solution to my question.
I have a php mysql table search that returns a result sucessfully. What I would like to be able to do is select one of the results to be inserted into a form. Basically when filling out a form there is a hyper link next to one of the inserts that opens a new window that has a search. I would like the user to be able to select one of the results from the search and have it automatically fill in the form item. Here is the code for the search (database info omitted).
<?php
if(isset($_POST['submit'])){
if(isset($_GET['go'])){
if(preg_match("/^[ a-zA-Z0-9]+/", $_POST['search'])){
$search=$_POST['search'];
$db=mysql_connect ("", "", "") or die ('I cannot connect to the database because: ' . mysql_error());
$mydb=mysql_select_db("");
$sql="SELECT CompanyID, ZipCat FROM A WHERE ZipCat LIKE '%" . $search . "%'";
$result=mysql_query($sql);
echo "<table border='1'>
<tr>
<th>Company ID</th>
<th>ZipCat</th>
</tr>";
while($row=mysql_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['CompanyID'] . "</td>";
echo "<td>" . $row['ZipCat'] . "</td>";
echo "</tr>";
}
}
else{
echo "<p>Please enter a search query</p>";
}
}
}
?>
The ZipCat is the section of the form that I would like to insert the search result (ZipCat) into. Any help would be appreciated!