davids_media Posted April 9, 2012 Share Posted April 9, 2012 I have two pages - one called category (cat.php) and one for products (item.php). I am currently having a dilemma - i want to click on a particular product from category page and view more of that product information in item.php Here is the code for the two pages; <?php error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", 1); require ('includes/config.inc.php'); include ('./includes/header.html'); require (MYSQL); include ('./includes/main.html'); if($id = isset($_GET['catID'])) { //Create and run query to get product category names for the selected cat ID $query = "SELECT `product`.`product`, `category`.`cat`, `product`.`prod_descr`, `category`.`cat_descr`, `product`.`price`, `product`.`image` FROM `product` LEFT JOIN `category` ON `product`.`catID` = `category`.`catID` WHERE `product`.`catID`='{$_GET['catID']}' ORDER BY `product`.`product`"; $r = mysqli_query($dbc, $query); //Create flag variable to determine if header needs to be displayed $showHeader = true; echo "<div id='right'>"; echo "<table cellpadding='5' cols='2'>"; while($row = mysqli_fetch_array($r)) { if($showHeader) { //Display category header echo "<h1>" . "<span>" . "# " . "</span>" . $row['cat'] . "<span>" . " #" . "</span>" . "</h1>" . "\n"; echo "<h2>" . $row['cat_descr'] . "</h2>" . "\n"; $showHeader = false; } //Display product name echo "<tr>"; echo "<td>". "<li>". "<a href='item.php?product={$row['product']}'>" . "<img src='db/images/".$row['image']."' height=50px width=50px />" . "</a>" . "</li>" . "</td>"; echo "<td>". "<li>" . "<a href='item.php?product={$row['product']}'>" . $row['product'] . "</a>" . "</li>" . "</td>"; echo "<td class='price'>" . "£". $row['price'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "</div>"; } include ('./includes/footer.html'); ?> <?php error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", 1); require ('includes/config.inc.php'); include ('./includes/header.html'); require (MYSQL); include ('./includes/main.html'); if($id = isset($_GET['prodID'])) { $query = "SELECT prodID, product, product_descr, image FROM product"; $r = mysqli_query($dbc, $query); $showHeader = true; echo "<div id='right'>"; if($showHeader) { //Display category header echo "<h1>" . "<span>" . "# " . "</span>" . $row['product'] . "<span>" . " #" . "</span>" . "</h1>"; echo "<h2>" . $row['prod_descr'] . "</h2>"; $showHeader = false; } echo "</div>"; } include ('./includes/footer.html'); ?> in item.php, when i want to view product information, using the echo, nothing is displayed on the page, how do i solve this? Quote Link to comment https://forums.phpfreaks.com/topic/260631-hyperlinkquerystring-problem/ Share on other sites More sharing options...
Psycho Posted April 9, 2012 Share Posted April 9, 2012 In the item.php page you are creating the links to the products like so echo "<td>". "<li>". "<a href='item.php?product={$row['product']}'>" . "<img src='db/images/".$row['image']."' height=50px width=50px />" . "</a>" . "</li>" . "</td>"; echo "<td>". "<li>" . "<a href='item.php?product={$row['product']}'>" . $row['product'] . "</a>" . "</li>" . "</td>"; note the href='item.php?product={$row['product']}' Then in the item.php page you are trying to reference the id using if($id = isset($_GET['prodID'])) You are setting the value using the variable name 'product', but trying to reference it as 'prodID'. The two need to be the same. Quote Link to comment https://forums.phpfreaks.com/topic/260631-hyperlinkquerystring-problem/#findComment-1335768 Share on other sites More sharing options...
davids_media Posted April 9, 2012 Author Share Posted April 9, 2012 I changed that, but in item.php i now have a problem which states that row ($row) is an undefined variable Quote Link to comment https://forums.phpfreaks.com/topic/260631-hyperlinkquerystring-problem/#findComment-1335776 Share on other sites More sharing options...
davids_media Posted April 9, 2012 Author Share Posted April 9, 2012 UPDATE!! silly me forgot to include a while loop in my code to fetch an array, i've got it working properly now thanks Quote Link to comment https://forums.phpfreaks.com/topic/260631-hyperlinkquerystring-problem/#findComment-1335778 Share on other sites More sharing options...
Psycho Posted April 9, 2012 Share Posted April 9, 2012 Marking topic solved. Quote Link to comment https://forums.phpfreaks.com/topic/260631-hyperlinkquerystring-problem/#findComment-1335821 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.