Need to display one item
Posted: Wed Apr 29, 2009 12:45 pm
I'm currently using a database of books where my PHP page will list all the books after each other. The code I'm going to use for this is:
I also want to create a HTML form where a user can select a specific book to display.
Any ideas how to implement this?
I'm guessing i'll use POST method for the form but I'm not sure how I can dispaly the book so a user can pick just one.
Any guidance appreciated.
Code: Select all
<?php
$con=mysql_connect("localhost","username","password);
if(!$con)
{
die("Cound not connect: ".mysql_error());
}
mysql_select_db("my_db",$con);
$sql = "SELECT * FROM Books";
$result = mysql_query($sql);
while($row=mysql_fetcg_array($result)
{
echo $row['ID']."<br>";
echo $row['Title']."<br>";
echo $row['Author']."<br>";
echo "<img src='."$row['Image']"."'><br>";
echo $row['Stock']."<br>";
}
mysql_close($con);
?>
Any ideas how to implement this?
I'm guessing i'll use POST method for the form but I'm not sure how I can dispaly the book so a user can pick just one.
Any guidance appreciated.