I'm new to the PHP Programming and I have a problem with dynamic urls. I load images from the database (in a row) and I want to make them dynamic urls, that redirect to the same page. The problem is that this page must have different ID for each image, but when i try it only the first image redirect and has wrong ID. Can somebody help?
This's the code I use.
<?php
if(isset($_GET['ID'])) {
require_once 'connection.php';
$ID = mysqli_real_escape_string($con, $_GET['ID']);
$link = "SELECT * FROM books";
$resultlink = mysqli_query($con, $link) or die("Bad Query: $link");
$image_query = "SELECT * FROM bookscategory, books WHERE idc='$ID' AND
(idc=idcateregory AND idnewpop=1)";
$result2 = mysqli_query($con, $image_query) or die("Bad Query:
$image_query");
$row2 = mysqli_fetch_array($result2);
}
else {
header ('Location: ..\Index.php');
}
?>
<?php
do {
if(mysqli_num_rows($resultlink) > 0) {
do {
echo"<a href='Book.php?ID={$rowl['idBook']}'></a>";
} while($rowl = mysqli_fetch_array($resultlink));
} else {
echo"<No Link>";
}
echo '<img alt="_" width="115" height="170" class="bookImage" src="'.$row2['img_dir'].'" />';
} while($row2 = mysqli_fetch_array($result2));
?>