I have two files : productlist.php shows all photos each with a detail button that you can click. productdetail.php shows details of one specific photo with image and description.
However, when I click the detail button in productlist.php page, it directs to productdetail.php page but cannot see image or description.
Below are codes in productlist.php:
<?php
$link = mysql_connect("xxx", "xxx", "xxx");
mysql_select_db( "xxx" );
$sql = "SELECT * FROM products order by createdate desc";
$result = mysql_query( $sql, $link );
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
<div class="productlist_content">
<div class="product_list">
<h1><?=$line["name"];?></h1>
<img class="product_list_image"
src="<?=$line["image"];?>" width="140" height="187"><br><br>
<a href="productdetails.php?id=<?=$line["id"];?>">
<img src="images/details.gif" width="60" height="20" border="0">
</a>
</div>
</div>
<?php
}
?>
Below are codes in productdetail.php:
<?php
if ( $id != "" )
{
$link = mysql_connect("xxx", "xxx", "xxx");
mysql_select_db( "xxx" );
$sql = "SELECT * FROM products WHERE id = '$id'";
$result = mysql_query( $sql, $link );
$line = mysql_fetch_array($result, MYSQL_ASSOC);
$id = $line["id"];
$name = $line["name"];
$description = $line["description"];
$image = $line["image"];
}
?>
<div class="product_name"><b><?=$name;?></b><br></div>
<div><img class="product_image" src="<?=$image;?>">
<div class="product_description">
<?=str_replace("\n", "<BR>", $description);?>
</div>
</div>
<div class="backbutton">
<a href="productlist.php">
<img src="images/btn_back.gif" width="38" height="16" border="0">
</a>
</div>