
Originally Posted by
Dr Livingston
What a difference it would make if only people would break out of PHP when they require a A HREF link passing some variables.
Point: With a decent editor that can highlight syntax; you don't see bugs when you ECHO a A HREF link.
Try (if this isn't chewed up again):
.
.
$name_id = $row["product_name"];
?>
<p>
<a href="show_news.php?product_id=<?php echo($p_id); ?>">news</a>
</p>
<?php
.
.
.
Also there is a very apparent error within your A HREF link anyways... though for your future sanity you'll know better to break out of PHP for using HTML markup.
Thanks for reply. Still stuck though!
news.php
PHP Code:
<?php
$query = 'SELECT product_id from product';
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$name_id = $row["product_id"];
?>
<a href="show_news.php?product_id=<?php echo($name_id); ?>">news</a>
<?php } ?>
show_news.php
PHP Code:
<?php
$name_id = $_GET['product_id'];
echo $name_id;
$query = 'SELECT product_id, product_name from product where product_id = $name_id';
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
echo $row[product_id];
echo $row[product_name];
}
?>
The problem seams to lie with the $name_id I have used in the query. If i set it to =1,2,3 etc then it works fine. Any suggestions?
Bookmarks