stuart7398 Posted March 25, 2008 Share Posted March 25, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/97814-trying-to-link-to-a-product-page/ Share on other sites More sharing options...
aschk Posted March 25, 2008 Share Posted March 25, 2008 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... Quote Link to comment https://forums.phpfreaks.com/topic/97814-trying-to-link-to-a-product-page/#findComment-500437 Share on other sites More sharing options...
stuart7398 Posted March 25, 2008 Author Share Posted March 25, 2008 hi. yes, the profilepage displays detailed product information. the links pages displays 10 images linked to each profile. my title bar shows the correct 'profile=id' but not showing each profiles different data. Quote Link to comment https://forums.phpfreaks.com/topic/97814-trying-to-link-to-a-product-page/#findComment-500442 Share on other sites More sharing options...
aschk Posted March 25, 2008 Share Posted March 25, 2008 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... Quote Link to comment https://forums.phpfreaks.com/topic/97814-trying-to-link-to-a-product-page/#findComment-500464 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.