I have an image that is displayed from a table and I want the user to be able to click the image which directs them to a page that returns the rest of the data for that row. Do I need a php loop for this? I can't quite figure it out. This returns the Last Name, First Name, and an Image:
<?php
if (isset($_GET['LastName'])) {
$ln = $_GET['LastName'];
}
include 'connection.php';
$query = "SELECT * FROM residents WHERE LastName like '$ln%' ";
$result = mysql_query($query);
while($person = mysql_fetch_array($result)) { ?>
<div class="media col-sm-4">
<a class="pull-left" href="redirectionpage.php?<?php echo $person['ID'];?>.php">
<img class="media-object" src="upload/<?php echo $person['Picture'];?>" width="100" height="100"/>
</a>
<div class="media-body">
<h4 class="media-heading"><?php echo $person['LastName'] . ", " . $person['FirstName']; ?></h4>
</div>
</div>
<?php }>?
Is the best way to accomplish this by redirecting the user to a new page and using a mysql statement to display the new data?
This is the code for the other page:
<?php
//Gets data from the database
include ('header.php');
include ('footer.php');
include ('connection.php');
$query = "SELECT * FROM residents WHERE ID = LastName LIMIT 1";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
$outputpicture.='<div><p><img src="upload/' . $row['Picture'].'" width="450" height="550"/></p></div>';
$outputname.= $row['LastName'] . ", " . $row['FirstName']. '<br />';
$outputspouse.= $row['Spouse']. '<br />';
$outputrelatives.= $row['Relatives']. '<br />';
$outputaddress.= $row['Address']. '<br />';
$outputbirthday.= $row['Birthday']. '<br />';
$outputbegan.= $row['BeganResidence']. '<br />';
$outputended.= $row['EndedResidence']. '<br />';
$outputformer.= $row['FormerResidence']. '<br />';
$outputcareer.= $row['Career']. '<br />';
$outputeducation.= $row['Education']. '<br />';
$outputmaritalstatus.= $row['MaritalStatus']. '<br />';
$outputsiblings.= $row['Siblings']. '<br />';
$outputspecialinterests.= $row['SpecialInterests'].'<br />';
}
?>