Hi,
I want the data that is entered in my form to be submitted to the table that is selected in the drop down menu. How do I use php to use $dropdownselection as the table selected in the drop down menu and this is the the table to submit the form data too. Hope I explained my question well enough.
<?
$usr = "me";
$pwd = "mine";
$db = "dnc";
$host = "localhost";
# connect to database
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
?>
<html>
<head>
<title>Insert New NC Job</title>
</head>
<body bgcolor="#ffffff">
<h2> Add New Job </h2>
<?
# this is processed when the form is submitted
# back on to this page (POST METHOD)
if ($_SERVER['REQUEST_METHOD'] == "POST"
{
# escape data and set variables
$PART_NUMBER = addslashes($_POST["PART_NUMBER"]);
$MACHINE = addslashes($_POST["MACHINE"]);
$NEED_DATE = addslashes($_POST["NEED_DATE"]);
$NOTES = addslashes($_POST["NOTES"]);
# setup SQL statement
$sql = " INSERT INTO $dropdownselection ";
$sql .= " (PART_NUMBER, MACHINE, NEED_DATE, NOTES) VALUES ";
$sql .= " ('$PART_NUMBER','$MACHINE','$NEED_DATE','$NOTES') ";
#execute SQL statement
$result = mysql_query($sql, $cid);
# check for error
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
print "<h3><font color=red>New Job Added</font></h3>";
}
?>
<form name="fa" action="record-add.php" method="POST">
<table>
<tr><td><b>Project Name:</b></td><td>
<?
echo "<select name='dropdownselection'>";
$result = mysql_list_tables($db);
while($row = mysql_fetch_row($result)){
echo"<option value='$row[0]<br>\n'>$row[0]<br>\n";
}
echo "</select>";
?></td></tr>
<tr><td><b>Part Number: </b> </td><td><input type="text" name="PART_NUMBER" size=40></td></tr>
<tr><td><b>Machine: </b> </td><td><input type="text" name="MACHINE" size=40></td></tr>
<tr><td><b>Need Date: </b> </td><td><input type="text" name="NEED_DATE" size=20></td></tr>
<tr><td valign=top><b>Notes: </b> </td><td> <textarea name="NOTES" rows=5 cols=40></textarea></td></tr>
<tr><th colspan=2><p><input type="submit" value="Add Job"></p></th></tr>
</table>
</form>
</body>
</html>
Blizz
I want the data that is entered in my form to be submitted to the table that is selected in the drop down menu. How do I use php to use $dropdownselection as the table selected in the drop down menu and this is the the table to submit the form data too. Hope I explained my question well enough.
<?
$usr = "me";
$pwd = "mine";
$db = "dnc";
$host = "localhost";
# connect to database
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
?>
<html>
<head>
<title>Insert New NC Job</title>
</head>
<body bgcolor="#ffffff">
<h2> Add New Job </h2>
<?
# this is processed when the form is submitted
# back on to this page (POST METHOD)
if ($_SERVER['REQUEST_METHOD'] == "POST"
{
# escape data and set variables
$PART_NUMBER = addslashes($_POST["PART_NUMBER"]);
$MACHINE = addslashes($_POST["MACHINE"]);
$NEED_DATE = addslashes($_POST["NEED_DATE"]);
$NOTES = addslashes($_POST["NOTES"]);
# setup SQL statement
$sql = " INSERT INTO $dropdownselection ";
$sql .= " (PART_NUMBER, MACHINE, NEED_DATE, NOTES) VALUES ";
$sql .= " ('$PART_NUMBER','$MACHINE','$NEED_DATE','$NOTES') ";
#execute SQL statement
$result = mysql_query($sql, $cid);
# check for error
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
print "<h3><font color=red>New Job Added</font></h3>";
}
?>
<form name="fa" action="record-add.php" method="POST">
<table>
<tr><td><b>Project Name:</b></td><td>
<?
echo "<select name='dropdownselection'>";
$result = mysql_list_tables($db);
while($row = mysql_fetch_row($result)){
echo"<option value='$row[0]<br>\n'>$row[0]<br>\n";
}
echo "</select>";
?></td></tr>
<tr><td><b>Part Number: </b> </td><td><input type="text" name="PART_NUMBER" size=40></td></tr>
<tr><td><b>Machine: </b> </td><td><input type="text" name="MACHINE" size=40></td></tr>
<tr><td><b>Need Date: </b> </td><td><input type="text" name="NEED_DATE" size=20></td></tr>
<tr><td valign=top><b>Notes: </b> </td><td> <textarea name="NOTES" rows=5 cols=40></textarea></td></tr>
<tr><th colspan=2><p><input type="submit" value="Add Job"></p></th></tr>
</table>
</form>
</body>
</html>
Blizz