Forum Moderators: coopster
$dbc = @mysql_connect("localhost","username","password");
@mysql_select_db("rezznor_qtesting") or die ("Could not select the database: " . mysql_error() );
$query = "SELECT * FROM tests";
$result = mysql_query ($query);
echo "<form action = " . $_SERVER['PHP_SELF'] . " method = 'post'>";
echo 'Select test:';
echo '<select name = "testName">';
if ($result)
{
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
echo "<option value = '" . $row[1] . "'>" . $row[1] . "</option>";
}
}
echo "</select>"; Now I want to get the value of that text box and update another db table. And just to make sure something is actually being posted, I echo the variable.
$tname = $_POST['testName'];
$query1 = "UPDATE tests SET numberofQuestions = (tests.numberofQuestions + 1) WHERE testName = '" . $tName . "'";
echo $query1;
echo "<p>tName = " . $tName; Looks like everything should work ok, but it keeps coming back with an empty result. I get
$tName =
Any ideas on what could be causing the problem?