WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : PHP Random rss feeds - selects 49 random feeds from an unlimited list and displays them on your website. It's Ideal for those moments when you got 5 minutes and dont know which one of your feeds to read.
Categories : PHP, Rich Site Summary (RSS), Arrays Click here to Update Your Picture
Tony thom
Date : Jun 16th 2007
Grade : 3 of 5 (graded 2 times)
Viewed : 6920
File : 4657.zip
Images : No Images for this code example.
Search : More code by Tony thom
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
Like this code?
Show the author your appreciation.
 

This is my first post so i hope you like it.
The following selects 49 random feeds from an unlimited list and displays them on your website. It's Ideal for those moments when you got 5 minutes and dont know which one of your feeds to read. See it in action here : http://www.ozonew4m.com/random-webmaster-feeds.php

First of all lets pull all our rss urls from the text file and put them in an array
<?php
$chars
= "";
$chars = file('feedlist.txt');
?>


Next we create a nice little function that will jumble all our urls around inside the array and retrieve 49 random results in an array according to a paramaters we specify.
These are ($feedarray,$amounttoretrieve,randomkey)

<?php
function random_subarray($ary, $len, $key) {     
srand($key);     shuffle($ary);
     return
array_slice($ary, 0, $len);
}
?>


now we use microtime to generate a random key for the function.
<?php
srand
((double)microtime()*1000000); 
$code = rand(0,100);
?>


Now we have the data we need call the function.The following tells the function we want 49 results randomised using our random key. (NOTE: A static key will yeild static results)

<?php
$fred
= (random_subarray($chars, 49, $code));
?>


Now all we need to do is go through our array and display our reslts in a mystery graph so we can choose which one to read.
The following is optimised to display 7x7=49 results but you can display them how you wish.

<?php
$rows
= 7;
$count = 0;
echo
"<h1> Random rss News </h1>";
echo
"<h2>Select any of the boxes below to view a news feed</h2>";
echo
"<p>The following table retrieves a selection of 49 feeds from a growing list and displays them randomly. </p>";
echo
"<table width='100%'><tr><td align='center'><b>Enjoy the Feeds</b><table cellpadding='10'><tr>";

foreach (
$fred as $key) {
   
$count++;
echo
"<td><a href='rssfeed.php?feed=$key'><img src='mysteryfeed.jpg'width='25'height='25'style='border: 0;'alt='feed $count' /></a></td>";
    if (
$count % $rows == 0) {
    if (
$count != 49) {
        print
"</tr><tr>";
}
    }
    if (
$count == 49) {
        print
"</tr>";
    }
}
echo
"</table><p><a href='feedslist.php'>View a complete list of feeds.</a><br /></p>";
echo
"</td></tr></table>";
?>


If you download the zip file it also contains a page to display the feeds, a list off webmaster feeds, a page to display a full list of your feeds






RSS parser using PHP5 and simpleXML
Categories : Rich Site Summary (RSS), PHP, XML
Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP, Arrays, Date Time, Databases, MySQL
Stepping through a numbered array with each() and list()
Categories : PHP, Arrays
HTML_Graphs uses PHP to provide a consistent interface for creating HTML based charts. The user of the class sets up arrays that are passed to html_graph() which then takes care of all the messy HTML layout.
Categories : Graphics, Arrays, PHP, PHP Classes, Charts and Graphs
grab the result of any calculation you submit to the Google Calculator.
Categories : PHP, Arrays, Web Services, Regexps, Math.
Array Insertion
Categories : PHP, PHP Classes, Arrays
quick sort for associative arrays
Categories : Algorithms, Arrays, PHP
How to load a query result into a PHP Array
Categories : PHP, Databases, Arrays, MySQL
Link Submition - Allow your visitors to submit links to the site.
Categories : PHP, Arrays, Filesystem, Beginner Guides
Dynamic Loading of XML array data into ComboBox and Display XML data using PHP + DOM + Javascript.
Categories : PHP, Java Script, DOM XML, XML, Arrays
How to pass an array from one PHP Script to another via an HTML form
Categories : PHP, HTML and PHP, Arrays
Tag content retrieval from websites with preg_match
Categories : PHP, Regexps, Arrays, HTML and PHP
Pageinfo: Array containing page URI, page query string (parameters), request method (GET or POST) and the complete URI
Categories : Variables, PHP Options and Info, Arrays, URLs, PHP
Football News Aggregator
Categories : PHP, Object Oriented, PHP Classes, Rich Site Summary (RSS), HTML and PHP
A database abstraction layer for the PHP Oracle 8 module (available from PHP 3.0.5). It supports persistent connections, fetching rows into arrays, prepare/execute (variable binding) and has a new and improved error interface.
Categories : Databases, Oracle, PHP, Arrays, Variables