Reputation: 23
I'm trying to put a link around data in a table. So if the user clicks on the link it will bring them to the edit page for that item. Every time I put the code in the data will disappear from the table. Here is the code for my page I'm working on:
I'm trying to put clickable data at the start of the table code
<?php include '../view/header.php'; ?>
<div id="main">
<h1>Product List</h1>
<div id="content">
<!-- display a table of products -->
<h2><?php echo $name; ?></h2>
<table>
<tr>
<th>Code</th>
<th>Name</th>
<th class="right">Version</th>
<th> </th>
</tr>
<?php foreach ($products as $product) : ?>
<tr>
<td> <a href="?action=view_product&product_id=<?php echo $product['productCode']; ?>"</a></td>
<td><?php echo $product['name']; ?></td>
<td class="right"><?php echo $product['version']; ?></td>
<td><form action="." method="post">
<input type="hidden" name="action"
value="delete_product" />
<input type="hidden" name="productCode"
value="<?php echo $product['productCode']; ?>" />
<input type="submit" value="Delete" />
</form></td>
</tr>
<?php endforeach; ?>
</table>
<p><a href="?action=show_add_form">Add Product</a></p>
</br>
</div>
</div>
<?php include '../view/footer.php'; ?>
Upvotes: 0
Views: 234
Reputation: 71384
You don't have any closing </a>
tag and nothing between the opening <a>
tag and where the closing tag should be. Here is the problem:
<td> <a href="?action=view_product&product_id=<?php echo $product['productCode']; ?>"></td>
This should be something like:
<td><a href="?action=view_product&product_id=<?php echo $product['productCode']; ?>"><?php echo $product['productCode']; ?></a></td>
Upvotes: 0
Reputation: 69
you are missing the closing tag for your anchor. It should be:
<td> <a href="?action=view_product&product_id=<?php echo $product['productCode']; ?>"><?php echo $product['productCode']; ?></a></td>
Upvotes: 0
Reputation: 1053
May not be the issue, but I don't see a closing anywhere for the:
<a href="?action=view_product&product_id=<?php echo $product['productCode']; ?>
Upvotes: 1