I have a database of over 900 products.

What i am hoping to create is a website that pulls the Product information from a database using its Product ID.

The products are displayed according to their sub category:

SELECT  `Product_ID`, `Product_picurl`, `Product_Name`, `Product_Description`, `Product_price`, `Product_Category`, `Product_Pdf`, `Product_Cart`, `Product_Features`, `Product_subcat`, `Key` FROM `prod_listing` where `Product_subcat` = 'Absorption Panels'

Once the user Clicks the product, the database should then reteive the data based on its Product ID.

What would i need to change inorder to get the above code to do what i want?

Thanks in advance

Recommended Answers

All 5 Replies

you would need to query the database with something along the lines of:

$query = "SELECT * FROM `prod_listing` WHERE Product_ID = '$id'";

Where $id is the product id that was clicked on

Thats exactly what i want but dont know how to do it!!

what you could do is add the product id into the querystring and on another page say product.php have something like this:

<?php
    $id = $_GET['id'];

    $query = "SELECT * FROM `prod_listing` WHERE Product_ID = '$id'";

    $result = mysql_query($query);
?>

after that you would juse need a while loop or summat similar just to extract all of the details of the product.

Does that help you?

<?php
$id = $_REQUEST;
$query = "SELECT * FROM 'prod_listing' WHERE Product_ID = '$id'";
$result = mysql_query($query);
while($data=mysql_fetch_row($query)){
echo"
<tr><td>Product_ID</td><td>$data[0]</td
</tr><tr>
<td>Product_Name</td><td>$data[2]</td
</tr><tr>
<td>Product_Description</td><td>$data[3]</td
</tr>
";
}
?>
hope this help you..

Cheers Guys!!!!!!!!!!

Here is what im using..

<?php
    //--------------- Connection Script ----------------------------\\
    $username = "*";
    $password = "*";
    $hostname = "*";
    $dbh = mysql_connect($hostname, $username, $password)
    or die("Unable to connect to MySQL");
    //------------------- Select Database --------------------------\\
    $selected = mysql_select_db("dutty_dp",$dbh)
    or die("Could not select first_test");
    ?></head>
<?php  // <------------------------------In your code there is no "php" here to tell the browser it is php and not HTML
    $query = "SELECT`Product_Id`, `Product_picurl`, `Product_Name`, `Product_Description`, `Product_price`, `Product_Category`, `Product_Pdf`,
    `Product_Cart`, `Product_Features`, `Product_subcat`, `Key` FROM `prod_listing` where `Product_subcat` = 'External Interfaces'"; 

    $result = mysql_query($query);
?>
<table width="57%" border="0" cellpadding="1" cellspacing="0" bordercolor="#FFFFFF">
  <?php while ($row=mysql_fetch_array($result)) { ?>
  <tr bordercolor="#000000"> 
    <td height="16" colspan="3" valign="top"><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <strong><?php echo $row["Product_Name"];?></strong> / <em> <?php echo $row["Product_Id"] ;?></em></font></div></td>
  </tr>
  <tr bordercolor="#000000"> 
    <td width="8%" height="57" valign="top"><div align="justify"> 
        <p align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="/test1.php?id=<?php echo $row["Product_Id"] ;?>">
		<img src="<?php echo $row["Product_picurl"];?>" alt="" name="" border="0"></a></font></p>
        </div></td>
    <td width="76%" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row["Product_Description"];?></font></td>
    <td width="16%" valign="middle"><p align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&pound;<?php echo $row["Product_price"];?></font></p>
      <p align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="<?php echo $row["Product_Cart"];?>">Add 
        to Cart</a></font></p><p align="center"><a href="/test1.php?id=<?php echo $row["Product_Id"] ;?>">test</a></p></td>
  </tr>
  <tr> 
    <td height="20" colspan=3 valign="top"></td>
  </tr>
  <?php } //end of loop ?>
</table>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.