Xeven Posted April 8, 2008 Share Posted April 8, 2008 Can anyone exlpain how this is done or how I am able to do this. Basically I have the following echo "<td width='200'>".$row['pd_name']."</td>"; Where 'pd_name' is a field in a table which contains lots of names pretty much. Now I can display all these names in a table, simple. But what I am having problems with is making a link from that name which has been generated. I want the link to pass the 'pd_name' information to a page called details.php and from there I need to be able to pull all details from the generated name. If that makes any sense at all. I am trying as best as possible to explain my little problem so I hope it makes sense. I thought that the echo statement would go something like echo "<td width='200'>""<a href='product.php? "ID OF THE NAME HERE" .$row['pd_name']."</td>"; I just have no idea how I can get the id to be generated for that link. Any help would be great. Link to comment https://forums.phpfreaks.com/topic/100212-solved-php-link/ Share on other sites More sharing options...
graham23s Posted April 8, 2008 Share Posted April 8, 2008 how about: <?php $product_id = $row['pd_id']; $product_name = $row['pd_name']; echo "<td width='200'><a href='product.php?id=$product_id'>$product_name</a></td>"; ?> Graham Link to comment https://forums.phpfreaks.com/topic/100212-solved-php-link/#findComment-512422 Share on other sites More sharing options...
Xeven Posted April 8, 2008 Author Share Posted April 8, 2008 Haha, I was thinking I must be able to define the field names and then use them to try and do it. Thanks Graham that worked like a treat. So when I write up the product.php page how would I pass the product_id to the next page to be able to create a mysql query on that product? Thanks again! Link to comment https://forums.phpfreaks.com/topic/100212-solved-php-link/#findComment-512433 Share on other sites More sharing options...
rofl90 Posted April 8, 2008 Share Posted April 8, 2008 $id = $_GET['id']; $sql = mysql_query("SELECT * FROM products WHERE id='$id'"); Link to comment https://forums.phpfreaks.com/topic/100212-solved-php-link/#findComment-512440 Share on other sites More sharing options...
Xeven Posted April 9, 2008 Author Share Posted April 9, 2008 So from the page which links to the product.php page, where would I post the "ID" which I would want to use in the query? Link to comment https://forums.phpfreaks.com/topic/100212-solved-php-link/#findComment-512821 Share on other sites More sharing options...
Xeven Posted April 9, 2008 Author Share Posted April 9, 2008 Forget that last question, I got it now Thanks for the help guys! Link to comment https://forums.phpfreaks.com/topic/100212-solved-php-link/#findComment-512855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.