If you're learning database programming, an integral part is being able to sort through your records. When using MySQL, the ORDER BY clause is an essential tool in retrieving and displaying the correct rows. In this tutorial you will learn how to sort and display records based on specific criteria.
The goal of this PHP Banner Rotator example tutorial is to teach the user how to properly load a list of image url’s into an array from a MySQL database, and then select a random array value using PHP’s array_rand() function. The random array value is the image’s url, which can then be printed out using the <img> tag to display a random image. This script also comes packaged with a mini-control-panel to easily add, modify and delete images from the database. Statistics regarding how many times each image has been displayed is also stored, and displayed within the control panel. Included at the footer of the script’s page is a small example of the banner rotator. Base functionality of the script can be executed in 9 or less lines.
- add, modify and remove images
- count number of times each image has been shown
- random banner rotation in action example given
- jQuery hide and show div based modification functionality