I am making a front end for a database of books and their writers. I can list them by genre so that you can more easily find them and on that page there are hyperlinks so that you can update and add chapters of the books.
I now want to give each hyperlink the same name as the book it refers to, but I can't figure out how to give an href a variable name.
I thought it would be possible this way, but it clearly isn't.
<td><a href="update_book_chapters.php?book_uri=http://dbpedia.org/resource/" . $bookName>$bookName</a></td>
Can anybody tell me whether it is possible to give an href a variable display name and if it is possible: how?
If that single line you posted is from some html template, then this is probably what you are looking for:
<td>
<a href="update_book_chapters.php?book_uri=http://dbpedia.org/resource/<?php echo urlencode($bookName) ?>">
<?php echo htmlentities($bookName) ?>
</a>
</td>
Depending on your php setup you might be able to use this more compact syntax:
<td>
<a href="update_book_chapters.php?book_uri=http://dbpedia.org/resource/<?= urlencode($bookName) ?>">
<?= htmlentities($bookName) ?>
</a>
</td>