My code already creates a table of images of record albums covers from a mysql query. I'm trying to add a link to the images that will send the image "id" to another page. This page will be a template for all linked images. The passed id will allow me to query the table for information about that particular album.
<?php
include('conn.php');
$loop = mysqli_query($conn, "SELECT * FROM vinyl ORDER BY RAND() LIMIT 32") or die (mysqli_error($conn));
$column_count = 4;
$i = 1;
echo '<table cellpadding="2">';
while ($row = mysqli_fetch_array($loop))
{
$id = $row['id'];
$artist = $row['artist'];
$album = $row['album'];
$image = $row['coverA'];
$image_src = "uploads/".$image;
$alt = $artist." >> ".$album;
if ($i == 1) { echo '<tr>'; }
?>
<td><a href="<?php echo $row['id'] ?>" ><img src="<?php echo $image_src; ?>" width="300px" height="300px" /></a></td>
<?php
$i++;
if ($i > $column_count) { $i=1; echo '</tr>'; }
}
echo '</table>';
?>
Your link is just the id of the row. If you want to send it as a variable, first you need the url to the page, and then mark it as a GET variable.
<a href="somepage.php?id=<?=$row["id"]?>">
Then on somepage.php
:
$id = $_GET["id"];