Forum Moderators: coopster
<?php
require_once('Connections/myConnection.php');
$sql_query = "SELECT * FROM `imagetest` ORDER BY RAND() LIMIT 1";
$query = mysql_query($sql_query) or die(mysql_error());
//changed name so as not to confuse
while ($arrayImage = mysql_fetch_array($query, MYSQL_ASSOC)){
//assign vars
$image = $arrayImage['image'];
$address = $arrayImage['address'];
$name = $arrayImage['name'];
//see what your actually getting in that array
echo "<pre>";
print_r($arrayImage);
echo "</pre>";
echo "<a href=\"".$address."\" target=\"_blank\"><img src=\"".$image."\" alt=\"".$name."\"></a>";
}
?>
Ok, now how do I do that. I have the script to output the image, do I need another hyperlink.php page that has the echo "<a href=\"".$address."\" target=\"_blank\"><img src=\"".$image."\" alt=\"".$name."\"></a>"; in it and then on my html page call them both. If it is a random query how do I have both scripts have the same random query ID?
<?php
require_once('mysql_connect.php');
$id = $_GET["id"];
$query = mysql_query("SELECT id FROM imagetest WHERE id=$id") or die(mysql_error());
echo "$imageid";
?>
http://www.yourdomain.com/getimage.php?imageid=0