Jump to content

HTML a href not fully working with PHP and MYSQL


wikholmj

Recommended Posts

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...

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

<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>

Link to comment
Share on other sites

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.