Jump to content

Recommended Posts

Hi.

I have a page with products which I want to link to their profile page to show the full description.

My problem is that when I click each product link I get the same data show up in the profile page

 

<code>

ProfilePage.php

<?php

require '../conn.php';

require '../conndb.php';

$data = mysql_query("SELECT * FROM products") or die(mysql_error());

$info = mysql_fetch_array( $data );

{

Print "<table style='table-layout:fixed; width:100%'>";

</code>

 

<code>

Linkspage.php

<?php

require '../conn.php';

require '../conndb.php';

$data = mysql_query("SELECT * FROM `products` ORDER BY `purchase_date` DESC LIMIT 10") OR DIE (mysql_error());

if (mysql_num_rows($data) > 0 )

{

while($info = mysql_fetch_array($data))

{

Print "<p><a href='../pages/products.php?id=".$info['p_id']."'>".$info['name'] .

" {$info['col_2']}<img src=/pages/images/".$info['photo'] ." align='middle' width='80px' alt='Escort: Ambers Escorts' border='0'/><i>{$info['location']}</i></a></p>";

 

</code>

 

Any help appreciated,

Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/97814-trying-to-link-to-a-product-page/
Share on other sites

Taking a quick stab in the dark here (because I think some of your code may be missing due to the use of <code> tags. you are using the same SQL statement for both queries...

SELECT * FROM products

 

This is going to select ALL (*) the products from the products table...

What your url says doesn't magically select the particular product.  ::)

you need to change your SQL statement on the product page to represent the product_id you have given it.

e.g.

SELECT * FROM products WHERE product_id = $_GET['product_id']

 

The column "product_id" is a guess because I don't know what your actual column is called. Also i'm using the $_GET superglobal to retrieve the id from the url parameters. You WILL want to sanatize this input because it's currently not safe...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.