Work
$entryinput = $_GET["p"];
require("connection.php");
$table_name = "entry";
$table_name2 = "images";
if($entryinput == ""){
$sql = "SELECT id FROM $table_name ORDER BY id DESC LIMIT 1";
$result = @mysql_query($sql,$connection) or die ("Couldn't execute query.");
while ($row = mysql_fetch_array($result)) {
$entryinput = $row['id'];
}
}
$sql2 = "SELECT id, title FROM $table_name ORDER BY id DESC";
$result = @mysql_query($sql2,$connection) or die("Couldn't execute query 2.");
while ($row = mysql_fetch_array($result)) {
$listid = $row['id'];
$listtitle = $row['title'];
if($listid == $entryinput) {
$list_block .= "
$listtitle";
}
else {
$list_block .= "
$listtitle";
}
}
$sql3 = "SELECT * FROM $table_name WHERE id = \"$entryinput\"";
$entryresult = @mysql_query($sql3,$connection) or die("Couldn't execute query 3.");
while ($row = mysql_fetch_array($entryresult)) {
$entryid = $row['id'];
$title = $row['title'];
$date = $row['date'];
$description = $row['description'];
}
$sql4 = "SELECT * FROM $table_name2 WHERE artworkid = \"$entryid\"";
$imageresult = @mysql_query($sql4,$connection) or die("Couldn't execute query 4.");
$i = 1;
while ($row2 = mysql_fetch_array($imageresult)) {
$imageid = $row2['id'];
$caption = $row2['caption'];
$imageurl = $row2['imageurl'];
$image_block .= "

$caption
";
$link_block .= "
";
$i++;
}
$display_block = "
";
echo "$display_block";
?>