Display random image

In this tutorial topic you will modify the default.php page to show a random picture each time the page is reloaded.

  1. Open the default.php page.
  2. Create a new recordset. This will retrieve from the image_img table all the image details, and will also make use of the SQL function RAND() to associate to each entry a random number. Then, the entire recordset will be ordered by the random number that was generated. This ensures that all images in the table get an equal chance of being displayed.
  3. To create the recordset, click on the Plus (+) button of the Bindings tab. Since the SQL query is more complex than the Simple interface can handle, click on the Advanced button. Fill in the dialog box options as follows.
  4. Apply the Show Thumbnail server behavior using the rsImages recordset (as described in the Delete image page).

  5. You should now be able to load the page in a browser and see a random image from your database. You can refresh the page a few times to see different  images.