I need to get a random record from a table to display photo.
I need to use the province and classification to restrict the photo to be displayed only on that page.
table fields:
ID
prov
class
num (start at 1 and the go to last number of photo in group)
photoname
Is there a shorter way to get the ID of a record where i have filtered the search on class and prov?
<td height="242" align="center" valign="top" bgcolor="#339966">
<?php
$viewprov = rand(1,9);
$result = mysql_query("SELECT FROM province WHERE ID=$viewprov ",$db);
$myrow = mysql_fetch_array($result);
$prov = 'GA';
// print the list if there is not editing
$min = 1;
$result = mysql_query("SELECT FROM photolist WHERE clas='AD' AND prov='$prov' ",$db);
while ($myrow = mysql_fetch_array($result)) {
$max1 = $myrow['num'];
}
$viewthis = rand($min,$max1);
$result = mysql_query("SELECT * FROM photolist WHERE clas = 'AD' AND prov='$prov' AND num=$viewthis ",$db);
$myrow = mysql_fetch_array($result)
?>
<?php
$pathto='/home/umfula/public_html/images/';
$filename = $myrow["photoname"] ;
if (file_exists($pathto.$filename)) {
?>
<img src="../images/<? echo $myrow["photoname"] ?>" alt="<? echo $myrow["atrib"] ?>"><br>
<?php
} else {
?>
<img src="logosml.jpg" width="240" height="180"><BR>
<?php
}
?>
Is there a shorter way to get the ID of a record where i have filtered the search on class and prov?