Php Mysql Table Row Click To Display Details Of The Data
Solution 1:
You must have an Id field in your hotel
table you can include it and have an anchor tag to link to other page with this id,
actually some thing like this:
For SQL statement:
for SQL statement you select id and the previous fields that you had selected already, as usually id is a unique column in tables you can get detail of one row and show all detail of specied id.
Here in this page your sql statement should change to :
$sql = "SELECT id,hotel_img, hotel_name, hotel_address, hotel_phone FROM hotel";
and in the detail.php
page your SQL statement must be something like this(of course I didn't consider security stuff):
$sql = "SELECT * FROM hotel where id=".$_GET['id'];
for your table :
Here I just added a
tag call detail.php file with parameter id
that you can get it in details.php
for show details
echo"<tr>
<td><a href="http://yoursite.dev/detail.php?id=".$row["id"]>See Details</a></td>
<td><img src=".$row["hotel_img"]."></td>
<td>".$row["hotel_name"].
"<br />".$row["hotel_address"].
"
</td>
<td>".$row["hotel_phone"].
"
</td>
</tr>";
And in your detail.php
file you get parameter id
with $_GET['id']
and show more detail for specified id
Post a Comment for "Php Mysql Table Row Click To Display Details Of The Data"