Tuesday, March 22, 2011

Show random quotes on page every time a page is refreshed

This code can be used to show some random quotes or random links every time the page is loaded or refreshed.

$quote = array(
1 => "Random Quote 1",
2 => "This is sample quote 2",
3 => "check http://programming-in-php.blogspot.com",
4 => "it really works",
5 => "wooooooooooooooooooooow",
6 => "I am on twitter"
);
$randnum = rand(1,6);
echo "
Random Quote - $quote[$randnum]
";
?>

Deleting record with Ajax using prototype.js and PHP

Tutorial's structure includes three files:

  • index.php (with a list of record you want to delete)
  • delete.php (PHP code to delete records into your database)
  • prototype.js (to enable Ajax)
Step 1: include prototype.js
Download prototype.js and create a new page (index.php). Add this line of code in the tag on index.php to include prototype framework:

It's all. I hope it's clear :