I have two tables
1. table data column ItemID
2. table main column ItemID
enter the ItemId from 1 to 10 in table data.
in php form in select box fetch the ItemID from data.
but after select ItamId '1' or else and submit it does not save in table main column ItemID.
the code is below
- Code: Select all
function print_Form()
{
//to get ItemID from table data for form
$ItemID=mysql_query("SELECT ItemID FROM data");
$option5 = '';
while($row = mysql_fetch_assoc($ItemID))
{
$option5 .= '<option value = "'.$row['ItemID'].'">'.$row['ItemID'].'</option>';
}
//Form
$newform = "<br><form method=\"post\"action=\"{$_SERVER['PHP_SELF']}\">
<table>
<td>
<label><b>Item ID:</b></label>
<select >
echo .$option5;
</select>
</td>
<input type=\"submit\"value=\"Add Record\">
</table>
return $newform;
}
//saving record
function save_Record() {
$_GET["ItemID"]="";
$locationErr="";
$ItemID= (int) cleanString ($_GET['ItemID']);
//query
$query = "INSERT INTO main(ItemID)
VALUES ($ItemID)
//execute query
if(mysql_query ($query)) {
print "<div '>
Record added successfully </div>";
print print_Form(); //show form again
}else{
error_Message (mysql_error()); //if error in query
}
}