Tip: Show Random Photos Anywhere

  • It’s easy to show random photo uploads from your PhotoPost gallery anywhere on your site. This thread has the details, skip to the end for the latest, and the PHP code snippet for random photos is:
$host   = 'localhost';
$dbUser = 'root';
$dbPass = 'database-password';
$db = 'database-name';
mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error());

$result = mysql_query("SELECT id,cat,bigimage FROM pp_photos order by rand() LIMIT 1" ) or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
print "<a href="/photos/showphoto.php/photo/" . $row['id'] . ""><img src="/photos/data/" . $row['cat'] . "/thumbs/" .  $row['bigimage'] . ""></a>";

Comments are closed.