If I want to write a function that:
- places a different image from every time the page is loaded, what is my best way to go about this? So far this is what I have pieced together. I am missing a few elements that I could use some help on.
Thanks for any insight!
Mahalo
<?
function random_art($category_id){
$hostname = "localhost";
$db_name = "tbeckdesign_com";
$user_name = "vladimir";
$pass = "test123";
$connection = @mysql_pconnect($hostname, $user_name, $pass) or die("Couldn't Connect!");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database!");
$sql = "SELECT art_id
FROM Art
WHERE category_id = $category_id
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute this damn query.");
$row = mysql_fetch_array($result)
shuffle ($row);
echo "$row[0]";
}
?>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<? echo random_art(7); ?>
</body>