i have used the following piece of php code to select a random image from a mysql database to display on my site, adding to its completely dynamic nature. i have had problems with my server people though who refuse to install mysql and instead use access. i was wondering then if there is a way to make a random selection like this but just from a specified folderand without a database backend.
function random_art(){
$result = mysql_query ("select * from graphics");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit(); }
$total = mysql_num_rows($result);
$lucky = rand(1,$total);
$result = mysql_query ("select * from graphics where id=$lucky");
if (!$result) {
echo("<P>Error finding lucky image: " .
mysql_error() . "</P>");
exit(); }
echo '
<table width="170" height="120" border="2" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="20" background="images/grad grey-blue.jpg" align="center">Random Artwork
from ph1</td>
</tr>
<tr>
<td height="100" bgcolor="#EAEAEA">';
/* Display each random image ------------------------------------------------------------------- */
while ( $row = mysql_fetch_array($result) )
{
echo("<a href=\"new_records.php?click=images\"><img src=\"images/" . $row["filename"] . "\" border=\"0\" height=\"100\" width=\"170\" alt=\"CLICK 2 SEE OUR GALLERY!\" /></a>");
}
echo '
</td>
</tr>
</table>
';
}
cheers.