3 Replies - 533 Views - Last Post: 13 February 2014 - 01:57 PM

#1 Wolverine89  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 68
  • Joined: 14-January 14

Entire row as a Link

Posted 13 February 2014 - 01:14 PM

Hi guys,

I have a table. Which contains different books, data is received from an mysql database. I want an entire row to be a link. so someone can get more information about an specifik book.

<?php 
include ("db_connect.php");

$query = "SELECT image, title FROM Book";
$result = $conn->query($query);

echo '<table class="bordered">';
echo "<tr><th>IMAGE</th><th>TITLE</th><th>Author</th><th></th></tr>";

while ($row = $result->fetch_assoc()){
	echo "<tr>";
	
	$image = $row["image"];
	$title = $row["title"];
	
	echo '<td><img src="data:image/jpeg;base64,' . base64_encode($image) . '" width="70" height="90"/></td>';
	echo "<td>$title</td><td></td>";
	echo '<td><a href="?page=Cart"> Add </a></td>';
	
	echo "</tr>";
	
}

echo "</table>";

$result->close();
$conn->close();

?>



please, i really need your help. Thanks in advance

link below is showing the site!
http://puu.sh/6UOSg.jpg

Is This A Good Question/Topic? 0
  • +

Replies To: Entire row as a Link

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3352
  • View blog
  • Posts: 11,345
  • Joined: 12-December 12

Re: Entire row as a Link

Posted 13 February 2014 - 01:21 PM

You cannot make an entire row a hyperlink. You will have to wrap individual cell-content in separate a-tags.

That is, unless you want to go to the lengths of creating a transparent element and sitting it above the row, or using a Javascript click-event on the row/cells.
Was This Post Helpful? 0
  • +
  • -

#3 Wolverine89  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 68
  • Joined: 14-January 14

Re: Entire row as a Link

Posted 13 February 2014 - 01:50 PM

okay and if i wrap them in a tags what is the next step?

And how do i do that, can you give an example with the code above?

This post has been edited by Wolverine89: 13 February 2014 - 01:51 PM

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3352
  • View blog
  • Posts: 11,345
  • Joined: 12-December 12

Re: Entire row as a Link

Posted 13 February 2014 - 01:57 PM

Surely you know the syntax for an a-tag? If you don't then you should stop all your web-development now! :whistling:

https://developer.mo.../HTML/Element/a

So then you create the tag in php in the same way you do for all the other HTML content.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1