No problem.
This is a picture of what I am trying to do:
Your search “Florida” returned the following results:
Date From Date To ID (hidden column)
4/12/2010 5/6/2010 12
6/3/2010 6/20/2010 22
1/10/2011 3/6/2011 87
Share your feedback:
Congratulations and good luck!
Submit
I want the information submitted from the “Share your feedback” form field (comments) to be posted to the feedback mysql table with each hidden ID value. So in this case the feedback mysql table would receive the following values:
VID Comments
12 Congratulations and good luck!
22 Congratulations and good luck!
87 Congratulations and good luck!
There are 2 mysql tables with the following fields:
member – ID, Location, DateFrom, DateTo
feedback – ID, VID, Comments
The ID field in Member and the VID field in Feedback are connected so that the comments in the feedback table are related to a specific member in the member table. I can get the comments into the feedback table, but I cannot get the VID into it (i.e., the ID from the member table).
A user searches the member mysql table for members located in a certain city (Location). After submission, the user is taken to the searchresults.php page which returns the results and provides a form field (comments) for the user to provide feedback to the members in that location:
searchresults.php
<?php
$con = mysql_connect("localhost","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
$term = $_POST['location'];
$result = mysql_query("select * from member where Location like '%$term%'");
echo "<h3>Your search "" . $term . "" returned the following results:</h3>";
echo "<table border='1'>
<tr>
<th>From Date</th>
<th>To Date</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td align='center'>" . $row['DateFrom'] . "</td>";
echo "<td align='center'>" . $row['DateTo'] . "</td>";
echo "<td><input name=\"ID\" type=\"hidden\" value=\"" . $row['ID'] . "\"></td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
Right below this code on the same searchresults.php page is the following form for the user to complete:
<form action="comments.php" method="post" id="formstyle">
<textarea cols="20" name="comments" rows="2"></textarea><br />
<br />
<input name="Submit1" type="submit" value="Submit" /></form>
The form is processed by comments.php which submits the results to the Feedback mysql table:
comments.php
<?php
$con = mysql_connect("localhost","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
$sql="INSERT INTO feedback (VID, Comments)
VALUES
('$_POST[ID]','$_POST[comments]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
header("Location: post_advice.htm");
mysql_close($con)
?>
I hope that helps.