I have a form with a select list and a hidden field to save the selected
item. On submit another page is loaded with a few fields to be filled in
and submitted to a table. Using get I see the data is being passed from
the first page to the second properly, and the second page sends its
data properly. The hidden field from the first page is to be used by the
second page as the name of the table in the query. I have a place where
I echo the contents of the hidden field just to be sure it is correct,
and that does indeed show what I expect. I then make the query statement
point to the variable but it always responds that it cannot find the
table. The table does exist, the variable does contain the appropriate
table name, but is not being replaced by the name. What am I doing
wrong?

--
Chip W
www.wiegand.org
[EMAIL PROTECTED]

Below is the code for the first page --

<html>
<head>
<title></title>
</head>
<body>
<div align="center">
<?
$exercises=array("absflexor","absmachine","leglifts");

echo "<form action='workout-absflexor.php' method='get'>";
echo "<table width='70%' border='0' align='center'>";
echo "<tr><th align='center'><h2>Exercise Data Input</h2></th></tr>";
echo "<tr><th align='center'><select name='listbox'>";
echo "<option>$exercises[0]</option>";
echo "<option>$exercises[1]</option>";
echo "<option>$exercises[2]</option>";
echo "</select><br><br>";
echo "</th></tr></table>";
echo "<input type='hidden' name='exerciselist' value='$listbox'>";
echo "<input type='submit'>";
echo "</form>";
?>
</div>
</body>
</html>

And below is the code for the second page --

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
  <head>
    <title>Workout Data Entry Form</title>
<style type="text/css">
 body { background-color: aqua; }
 div.c1 {text-align: center}
</style>
  </head>
  <body>
    <div class="c1">
      <h2>Work-Out Data Entry Screen</h2>
      <form action="<? PHP_SELF ?>" method="get">
        <table summary="" width="60%" border="1" align="center"
bgcolor="green">
          <tr>
            <th>Weight</th>
            <td align="left"><input type="text" name="exercise"
maxlength="4"></td>
          </tr>
          <tr>
            <th>Reps</th>
            <td align="left"><input type="text" name="reps"
maxlength="4"></td>
          </tr>
          <tr>
            <th>Comments</th>
            <td colspan="2"><textarea cols="50" rows="3"
name="comments">
            </textarea></td>
          </tr>
          <tr><td><? echo $listbox; ?></td></tr>
        </table>
        <br />
        <input type="submit" name="submit" value="Send Data" /> <input
type="reset" />
      </form>
    </div>
  <?
  if(isset($submit)):
  $db = mysql_connect("localhost","root","carvin");
  if(!$db) error_message(sql_error());
  mysql_select_db("workout",$db) or die ("Ack! Where's the database?");
  $date = date("m-d");
  $sql = "insert into $listbox
values(NULL,'$date','$exercise','$reps','$comments')";
  mysql_query($sql) or die ("Ack! No response when I queried the
server!");
  endif;
  ?>
  </body>
</html>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to