I need help with the code for an items detail page.
When a user clicks on an item from the main page,
this link will say more details...
then when clicked it will take them
to my second page, an item detail page.
I am using the product id as the passing variable.
So on the item detail page, how would I set that up
for the select statement? Currently I don't know if I
am to use a limit or not. This is what I have so far
and its not working...
$table_name = "table";
$host = "localhost";
$user = "user";
$pass = "pass";
$db = "database";
//open database connection
$connection = mysql_connect("$host", "$user", "$pass")
or die(mysql_error());
//select database
$db = @mysql_select_db($db, $connection) or
die(mysql_error());
$sql = "select * from $table WHERE ProductID='ProductID'";
$result = mysql_query($sql,$connection) or die("Error: " . mysql_error());
$numrows = mysql_num_rows($result);
// We have no results
if ($num_rows == 0) {
echo "Sorry, we have no records";
} else {
// We have results so create a table to display them
//blah..blah..
//products table
/* Begin table to format data */
print "<center><table width=\"500\" border=\"1\" bordercolor=\"#EEEED1\" cellspacing=\"0\" cellpadding=\"0\">\n";
print "<tr><td align=\"center\" colspan=\"4\" bgcolor=\"#CDB5CD\">";
print "<strong>Products</strong>";
print "</td></tr>";
while($row=mysql_fetch_array($result)){
print "\t<tr>";
print "\t\t<td>" .$row['Name']. "<br><a target=\"_blank\" href=\"" . $row['Link']. "\">" . $row['Name'] . "</a></td>";
print "\t\t<td>" . $row['ProductID'] . "</td>";
print "\t\t<td><font color=\"#FF0000\">$" . $row['Price'] . "</font></td>";
print "\t\t<td align=\"center\"><img src=\"" .$row['Thumbnail']. "\" width=\"50\" height=\"50\"></td>";
print "\t</tr>";
}
print "</table></center>\n";
?>
The main page is working fine.
thanks in advance,
charles256