Displaying name instead of ID PHP MySQL
Posted
by Derek
on Stack Overflow
See other posts from Stack Overflow
or by Derek
Published on 2010-03-16T17:37:59Z
Indexed on
2010/03/16
17:41 UTC
Read the original article
Hit count: 209
Hi, I need something simple; I have page where a user clicks an author to see the books associated with that author. On my page displaying the list of books for the author, I want a simple HTML title saying: 'The books for: AUTHORNAME'
I can get the page to display author ID but not the name. When the user clicks the link in the previous page of the author, it looks likes this:
<a href="viewauthorbooks.php?author_id=<?php echo $row['author_id']?>"><?php echo $row['authorname']?></a>
And then on the 'viewauthorbooks.php?author_id=23' I have declared this at the start:
$author_id = $_GET['author_id']; $authorname = $_GET['authorname'];
And finally, 'The books for: AUTHORNAME, where it says AUTHORNAME, I have this:
echo $authorname
(With PHP tags, buts its not letting me put them in!) And this doesnt show anything, however if I change it to author_id, it displays the correct author ID that has been clicked, but its not exactly user friendly!! Can anyone help me out!
© Stack Overflow or respective owner