wikholmj Posted January 31, 2012 Share Posted January 31, 2012 Hey all, I'm working on a website to show various products. I am using PHP, HTML, MySQL. I have a products page which shows a table of products (either all or just products from a specific category). Currently, the page works fine, shows an image, brand, name, and price of each product. However, when I have tried to make the image and the brand and name a link, it doesn't fully work. In the page source it will show correctly, but on the webpage itself I cannot click on the links. I have scoured various forums and manuals and have tried all the various ways to code the <a href=> but it still does not work right. Here's a snippet of the code with the link... /*Other code above for MySQL queries, HTML table etc*/ <td> <?php echo '<a href="details.php?id=' . $row['id'] . '"><img src="resize.php?id=' . $row['id'] . '"/></a>'; ?> </td> <td> <?php echo "<a href=\"details.php?id=" . $row['id'] . "\">" . $row['brand'] . "<br>" . $row['name'] . "</a><br>"; echo "Price: $" . $row['price'] . "<br>"; ?> </td> I have even tried putting the <a href="details.php?id=<?php echo $row['id']; ?> ... </a> just between the <td> and </td>. I still can't click the links on the page, even though they are technically there. The page source will show <a href="details.php?id=1"> ... =2"> ... =3"> ... etc for each product that is displayed. If I actually type details.php?id=1 in my browser and go back to the products page the text will change color to the "visited link" color. Any insight into my dilemma? Thanks in advance... Quote Link to comment https://forums.phpfreaks.com/topic/256141-html-a-href-not-fully-working-with-php-and-mysql/ Share on other sites More sharing options...
digibucc Posted January 31, 2012 Share Posted January 31, 2012 why single quotes on the bottom link? the image loads fine on the top? what if you type a static link there, with no php, does that work? Quote Link to comment https://forums.phpfreaks.com/topic/256141-html-a-href-not-fully-working-with-php-and-mysql/#findComment-1313085 Share on other sites More sharing options...
PFMaBiSmAd Posted January 31, 2012 Share Posted January 31, 2012 If your links are not working, it's likely that the HTML syntax prior to that point is broken. Have you validated the complete resulting html of the page at http://validator.w3.org ? Quote Link to comment https://forums.phpfreaks.com/topic/256141-html-a-href-not-fully-working-with-php-and-mysql/#findComment-1313086 Share on other sites More sharing options...
wikholmj Posted January 31, 2012 Author Share Posted January 31, 2012 Found root of issue.... I am using a CSS stylesheet to create <div>'s for layout purposes. The products page is loading in the content section and the links are not working. When I type products.php (which displays all products) in my browser the page works completely as it is supposed to, links and all. What could be wrong with the CSS stylesheet to interrupt links? Here's my index.php code... <html> <head> <title>My Website</title> <link rel = "stylesheet" type="text/css" href="stylesheet.css"/> </head> <body> <div id="all"> <div id="head"> <?php include('header.php'); ?> </div> <div id="content"> <?php if(isset($_GET['page'])) { switch($_GET['page']) { case "products": include('products.php'); break; case "service": include('service.php'); break; case "map": include('map.php'); break; case "faqs":include('faqs.php');break; case "contact":include('contact.php');break; case "policies":include('policies.php');break; } } else include('welcome.php'); ?> </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/256141-html-a-href-not-fully-working-with-php-and-mysql/#findComment-1313092 Share on other sites More sharing options...
scootstah Posted January 31, 2012 Share Posted January 31, 2012 CSS isn't going to make links not work. Do you have a live page we can view to see the page source? Quote Link to comment https://forums.phpfreaks.com/topic/256141-html-a-href-not-fully-working-with-php-and-mysql/#findComment-1313102 Share on other sites More sharing options...
wikholmj Posted January 31, 2012 Author Share Posted January 31, 2012 No the website is not live yet. Which page source would you like to see? Not the code right? Quote Link to comment https://forums.phpfreaks.com/topic/256141-html-a-href-not-fully-working-with-php-and-mysql/#findComment-1313107 Share on other sites More sharing options...
scootstah Posted January 31, 2012 Share Posted January 31, 2012 The source surrounding (and including) the anchor tags. Quote Link to comment https://forums.phpfreaks.com/topic/256141-html-a-href-not-fully-working-with-php-and-mysql/#findComment-1313109 Share on other sites More sharing options...
wikholmj Posted January 31, 2012 Author Share Posted January 31, 2012 <div id="content"> <table cellpadding="2" cellspacing="4"> <tr> <td> <a href="details.php?id=1"><img src="resize.php?id=1"></a> </td> <td> <a href="details.php?id=1">Brand 1<br>Product 1</a><br>Price: $2.99<br> </td> <td> <a href="details.php?id=2"><img src="resize.php?id=2"></a> </td> <td> <a href="details.php?id=2">Brand 2<br>Product 2</a><br>Price: $2.99<br> </td> <td> <a href="details.php?id=3"><img src="resize.php?id=3"></a> </td> <td> <a href="details.php?id=3">Brand 3<br>Product 3</a><br>Price: $2.99<br> </td> </tr> <tr> <td> <a href="details.php?id=4"><img src="resize.php?id=4"></a> </td> <td> <a href="details.php?id=4">Brand 4<br>Product 4</a><br>Price: $2.99<br> </td> </tr> </table> </div> Quote Link to comment https://forums.phpfreaks.com/topic/256141-html-a-href-not-fully-working-with-php-and-mysql/#findComment-1313114 Share on other sites More sharing options...
wikholmj Posted February 1, 2012 Author Share Posted February 1, 2012 It was a CSS issue involving z-index. Thank you to everyone for the input. Quote Link to comment https://forums.phpfreaks.com/topic/256141-html-a-href-not-fully-working-with-php-and-mysql/#findComment-1313178 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.