yandoo Posted May 12, 2008 Share Posted May 12, 2008 Hi there, I was hoping for a little help and guidance please I have an image that is hyperlinked and i want to parse a value of the image as a url parameter to determine which records will be displayed.. Im thinking that assigning a static value to the image may do the trick (but tried and failed )and that value is then parsed....Is this possible?? How do i do this?? Any help much appreciated Thank you Link to comment https://forums.phpfreaks.com/topic/105278-image-hyperlink-to-parse-recordid/ Share on other sites More sharing options...
yandoo Posted May 12, 2008 Author Share Posted May 12, 2008 Hi there, Im kind of getting there, i modified this line to code to: <a href="products.php?recordID=T-Shirts"><img src="Images/t-shirt.jpg" alt="T-Shirts" width="100" height="72" border="0" /></a> I manually added the recordID as T-shirts. The problem is when trying to echo out the results as nothing appears?? Im using <?php echo $row_products ['ProductName'];?> It doesnt work??? Is this even possible? So it appears the value "T-Shirts" is not getting parsed..?? Please help me Thanks Link to comment https://forums.phpfreaks.com/topic/105278-image-hyperlink-to-parse-recordid/#findComment-539099 Share on other sites More sharing options...
revraz Posted May 12, 2008 Share Posted May 12, 2008 You dont show anything about $row_products and how you populate it so my best advice is to remove the space from $row_products and ['ProductName'] $row_products['ProductName'] Link to comment https://forums.phpfreaks.com/topic/105278-image-hyperlink-to-parse-recordid/#findComment-539100 Share on other sites More sharing options...
yandoo Posted May 12, 2008 Author Share Posted May 12, 2008 Hi there, Thanks for the speedy reply, I have tried the change you suggested (deleting space) and still have no records outputted??? Theres almost nothing to the code: <a href="products.php?recordID=T-Shirts"><img src="Images/t-shirt.jpg" alt="T-Shirts" width="100" height="72" border="0" /></a> <?php echo $row_products['ProductName'];?> Am i missing something here?? Thank You Link to comment https://forums.phpfreaks.com/topic/105278-image-hyperlink-to-parse-recordid/#findComment-539110 Share on other sites More sharing options...
revraz Posted May 12, 2008 Share Posted May 12, 2008 Where do you set $row_products['ProductName'] ? Link to comment https://forums.phpfreaks.com/topic/105278-image-hyperlink-to-parse-recordid/#findComment-539113 Share on other sites More sharing options...
yandoo Posted May 12, 2008 Author Share Posted May 12, 2008 Hi there, Sorry im being a doughnut here the SELECT query im using (which makes up entire page with image link and output code) code: <?php $colname_products = "-1"; if (isset($_GET['recordID'])) { $colname_products = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']); } mysql_select_db($database_RFW, $RFW); $query_products = sprintf("SELECT * FROM products WHERE ProductName = '%s'", $colname_products); $products = mysql_query($query_products, $RFW) or die(mysql_error()); $row_products = mysql_fetch_assoc($products); $totalRows_products = mysql_num_rows($products); Its wired because when i test it the url address bar shows CORRECT details. i.e.....products.php?recordID=T-Shirts. The SELECT query is suppose to output all products that have the same product name i.e. T-Shirts. Hope this helps Thank You Link to comment https://forums.phpfreaks.com/topic/105278-image-hyperlink-to-parse-recordid/#findComment-539117 Share on other sites More sharing options...
revraz Posted May 12, 2008 Share Posted May 12, 2008 You are not doing any looping to set $row_products to each key. So only the first one is getting set. Link to comment https://forums.phpfreaks.com/topic/105278-image-hyperlink-to-parse-recordid/#findComment-539150 Share on other sites More sharing options...
yandoo Posted May 12, 2008 Author Share Posted May 12, 2008 Hi there, For the purposes of testing i was trying it with out the While Loop, assuming ONLY the first record of the list is echoed. I have since then tried it with a while loop: <?php do { ?> <?php echo $row_products['ProductName'];?> <?php } while ($row_products = mysql_fetch_assoc($products)); ?> The thing is still Nothing is outputted??? I then tried the query SELECT FROM * products WHERE 'ProductName' = T-Shirt.....Within phpmyadmin and it is working fine also there.... I initially thought parsing a url parameter from an image would be quite straight forward.... But something is a miss as still not working?? Please Help - eek! Thanks Link to comment https://forums.phpfreaks.com/topic/105278-image-hyperlink-to-parse-recordid/#findComment-539297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.