Hi,
I'm trying to make a sort of maintainance-page to update my mysql table:
1, I display several records with several fields in a table (in the form of textboxes)- until here it's OK
2, I update as many records as I want and check the 'change' checkbox where I made changes.
I suppose there's a problem in my passing the data, because the message I always receive is:
Unable to update the table: Query was empty.
Any idea???
Thanks for your help in advance.
Krisztina
Here's what I wrote:
<html>
<head>
<title>12.6.</title>
</head>
<body bgcolor=white>
<?php
$db="yourhungary_uk_db";
$conn= mysql_connect();
if ( ! $conn)
die ("Cannot connect to the MySQL server.");
mysql_select_db ($db, $conn)
or die ("Cannot open $db:".mysql_error());
if (isset($id))
{
$parancs = mysql_query("UPDATE Hotels SET address='$address', website='$website', price='$price', region='$region' WHERE id=$id");
$eredmeny = mysql_query ($parancs);
if (!$eredmeny)
die ("Unable to update the table: ".mysql_error());
print "The table is now updated. ".mysql_affected_rows()." rows were changed.";
}
?>
<form action= "<? print $PHP_SELF ?>" method="POST">
<?php
$eredmeny = mysql_query("SELECT id, name, address, website, price, region FROM Hotels");
print "<table border=1>\n";
print "<tr>
<td><div class=2>Change</div></td>
<td><div class=2>Remove</div></td>
<td><div class=2>Name</div></td>
<td><div class=2>Address</div></td>
<td><div class=2>Website</div></td>
<td><div class=2>Price</div></td>
<td><div class=2>Region</div></td>
</tr>";
while ($egy_sor = mysql_fetch_array($eredmeny))
{
print "<tr>\n";
print "<td><input type=\"checkbox\" name=\"id[]\" value=\"$egy_sor[id]\"></td>\n";
print "<td><input type=\"checkbox\" name=\"remove[]\"></td>\n";
print "<td><div class=1>$egy_sor[name]</div></td>";
print "<td><input type=\"text\" name=\"address[]\" value=\"$egy_sor[address]\"></td>\n";
print "<td><input type=\"text\" name=\"website[]\" value=\"$egy_sor[website]\"></td>\n";
print "<td><input type=\"text\" name=\"price[]\" value=\"$egy_sor[price]\"></td>\n";
print "<td><input type=\"text\" name=\"region[]\" value=\"$egy_sor[region]\"></td>\n";
print "</tr>\n";
}
print "</table>\n";
mysql_close($conn);
?>
<input type="submit" value="Change">
</form>
</body>
</html>