Thanks for your time in replying.
Yes i do have the table fields totalhits and votes (actually image_hits and image_votes).
I understand most of the code you posted but really cant see how to implement the isset($_GET) thing.
I think it's probably better you look at what i've done till now and tell me if my logic was totally wrong or if there is a better way to do what i intend.
<?php
include 'header.php';
// Content
include 'admin/config.inc';
$db=mysql_connect("localhost",$uname,$pwd);
mysql_select_db($dbname,$db);
$result=mysql_query("select * from 4images_images");
$row=mysql_num_rows($result);
srand((double)microtime()*1234567);
$random1=rand(1,$row);
$random2=rand(1,$row);
if ($random2 = $random1)
{
$random2=rand(1,$row);
}
$sqlresult = mysql_query("SELECT * FROM 4images_images WHERE (image_id = $random1) OR (image_id = $random2)");
$maxwidth = "380";
$imgbattle = $row["image_battle"];
$imgbattle = $imgbattle + 1;
$HTML="\n<tr>\n";
while ($row = mysql_fetch_array($sqlresult))
{
$imageid=$row["image_id"];
$category=$row["cat_id"];
$imgrating=$row["image_rating"];
$imghits=$row["image_hits"];
echo "Image_ID:",$imageid;
$query="UPDATE 4images_images SET image_battle='$imgbattle' WHERE image_id=$imageid";
mysql_query($query) or die(mysql_error());
$imagename=$row["image_name"];
$mediafile=$row["image_media_file"];
$mediaURL="../media/data/media/$categoria/$mediafile";
$imagehw = GetImageSize($mediaURL);
$imagewidth = $imagehw[0];
$imageheight = $imagehw[1];
$imgorig = $imagewidth;
if ($imagewidth > $maxwidth) {
$imageprop=($maxwidth*100)/$imagewidth;
$imagevsize= ($imageheight*$imageprop)/100 ;
$imagewidth=$maxwidth;
$imageheight=ceil($imagevsize);
}
$HTML.="<td align=\"center\">";
$HTML.="<img src=\"../media/data/media/$category/$mediafile\" border=\"0\" width=$imagewidth height=$imageheight><br/>$imagename<br/>Number of battles: $imagebattle<br/>Actual Rating: $imgrating</td>\n";
}
$HTML.=" </tr><br/><br/>\n";
echo $HTML;
// End of Content
include 'footer.php';
?>
What i still dont understand is how to update the database depending on which picture i click. I display each picture in the while loop so i don't know what to put in the <a href> part.
There are probably lots of other errors in the code but
please bear with me because i'm still learning. :rolleyes: