你有一个错误在这行
valid($ProductName, $Quantity,$Price,);
应该
valid($ProductName, $Quantity,$Price,$error);
你有一个错误也else statment使用两个其他
它应该be
if(.....
else if (....
else { ...
编辑:
试试这个
function valid($id, $ProductName, $Quantity,$Price, $error)
{
?>
Edit Recordsif ($error != '')
{
echo '
}
?>
Edit Records | |
Product Name* | |
Quantity* | |
City* | |
}
include('config.php');
if (isset($_POST['submit']))
{
$ProductName = mysql_real_escape_string(htmlspecialchars($_POST['ProductName']));
$Quantity = mysql_real_escape_string(htmlspecialchars($_POST['Quantity']));
$Price = mysql_real_escape_string(htmlspecialchars($_POST['Price']));
if ($ProductName == '' || $Quantity == '' || $Price == '')
{
$error = 'ERROR: Please fill in all required fields!';
valid($id, $ProductName, $Quantity,$Price, $error);
}
else
{
mysql_query("UPDATE Stock SET ProductName='$ProductName', Quantity='$Quantity' ,Price='$Price' ")
or die(mysql_error());
header("Location: view.php");
}
}
else
{
echo 'Error!';
}
$query = mysql_query(" select * from Stock");
$row = mysql_fetch_array($query) ;
if (mysql_num_rows($query) == 0)
{
echo "No results!";
}
else if (mysql_num_rows($query) == 1)
{
$ProductName = $row['ProductName'];
$Quantity = $row['Quantity'];
$Price = $row['Price'];
valid($ProductName, $Quantity,$Price,$error);
echo "echo what you like here".
}
else
{
echo 'Error!';
}
?>