Hello,
I have made a little update script for my ICT project but for one reason or another it doesn't seem to work...
There's another form before the script that posts the values and some of the values are empty, but that shouldn't make a difference...
When the code is executed it doesn't update my table or print me back the data of the book after it tries to update.
I don't get any errors just, the page loaded, missing only one big print command, the one that has like 40 lines in it below--
Any ideas?
<?php
@mysql_connect("localhost", "basichy", "--")
or die("Could not connect to MySQL server!");
@mysql_select_db("basichy_ict") or die("Could not select basichy_ict database!");
$id = $_POST["id"];
$title = $_POST["title"];
$author = $_POST["author"];
$price = $_POST["price"];
$genre = $_POST["genre"];
$category = $_POST["category"];
$language = $_POST["language"];
$stock = $_POST["stock"];
$mstock = $_POST["mstock"];
$publisher = $_POST["publisher"];
$publishdate = $_POST["publishdate"];
$pages = $_POST["pages"];
$isbn = $_POST["isbn"];
$pic = $_POST["pic"];
$plot = $_POST["plot"];
$query = "UPDATE books SET title='$title', author='$author', price='$price', genre='$genre', category='$category', language='$language', stock='$stock', mstock='$mstock', publisher='$publisher', publishdate='$publishdate', pages='$pages', isbn='$isbn', pic='$pic', plot='$plot' WHERE id='$id'";
$resultt = mysql_query($query) or die(mysql_error());
include('/home/basichy/public_html/ict/beginning.php');
echo(" <style type=\"text/css\">
#result tbody tr.even td {
background-color: #2a5a8a;
}
#result tbody tr.odd td {
background-color: #578bb8;
}
</style>");
print "<center><div class=\"box\"><table id = result width=\"699\">";
// format and display returned row values.
$query = "SELECT id, title, author, price, genre, category, language, stock, mstock, publisher, publishdate, pages, isbn, pic, plot
FROM books WHERE id = '$id'";
$result = mysql_query($query) or die(mysql_error());
while (list($id, $title, $author, $price, $genre, $category, $language, $stock, $mstock, $publisher, $publishdate, $pages, $isbn, $pic, $plot) = mysql_fetch_row($result)):
print "<tr class='odd'><td><font color=\"white\">ID</td>
<td><font color=\"white\">$id</td></tr>
<tr class='even'><td><font color=\"white\">Title</td>
<td><font color=\"white\">$title</td></tr>
<tr class='odd'><td><font color=\"white\">Author</td>
<td><font color=\"white\">$author</td></tr>
<tr class='even'><td><font color=\"white\">Price (ytl)</td>
<td><font color=\"white\">$price</td></tr>
<tr class='odd'><td><font color=\"white\">Genre</td>
<td><font color=\"white\">$genre($category)</td></tr>
<tr class='even'><td><font color=\"white\">Language</td>
<td><font color=\"white\">$language</td></tr>
<tr class='even'><td><font color=\"white\">Current Stock</td>
<td><font color=\"white\">$stock</td></tr>
<tr class='odd'><td><font color=\"white\">Minimum Stock</td>
<td><font color=\"white\">$mstock</td></tr>
<tr class='even'><td><font color=\"white\">Language</td>
<td><font color=\"white\">$language</td></tr>
<tr class='odd'><td><font color=\"white\">Publisher</td>
<td><font color=\"white\">$publisher($publishdate)</td></tr>
<tr class='even'><td><font color=\"white\">Pages</td>
<td><font color=\"white\">$pages</td></tr>
<tr class='odd'><td><font color=\"white\">ISBN</td>
<td><font color=\"white\">$isbn</td></tr>
<tr class='even'><td><font color=\"white\">Plot</td>
<td><font color=\"white\">$plot</td></tr>
<tr><img src=\"$pic\" height=\"400\" width=\"300\"</tr>";
endwhile;
print "</table></div></center>";
include('/home/basichy/public_html/ict/end.html');
mysql_close();
?>