Chamza Posted July 13, 2009 Share Posted July 13, 2009 Hello everyone, I've been lurking these forums for the past several months, and have finally decided to register because I have a question that needs answering. Although I have some experience programming and designing, I am relatively new to PHP and would like to know if creating a website like Stumbleupon.com would be possible using PHP? What I am trying to do is create a website where there are certain categories, and certain webpages will be stored in each category. When a button is clicked, a random page among the list of websites I have stored is generated within the category. Meanwhile, the top of the page remains the same while the bottom goes to an existing website. If this sounds confusing, head on to stumbleupon.com and click the “Stumble” button at the top left and see how it works. Furthermore, would creating a website like StumbleUpon use AJAX? I don't know much about AJAX at all, but I can do research if need be. This sounds do-able to me, but I am also very new to programming and would like some seasoned programmers to chime in with ideas or any helpful tips in creating a website like this. Please guide me in any direction that'll make this project easier, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/165756-creating-a-website-like-stumbleupon/ Share on other sites More sharing options...
Stuie_b Posted July 13, 2009 Share Posted July 13, 2009 Yes this is quite possible to achieve with php, You would need to use mysql or another type of database to store your url's and other data, once you had the url's you could set php to simply randomly select one from the database and load the url Here's a very basic example of how to achieve this, //FILE: index.php <?php //Stumbleupon example @$do = $_REQUEST['do']; $urls = array( 'http://www.google.co.uk', 'http://www.hotmail.com' ); //Build a list of urls if(isset($do) or !$do){ //Just so we can reload a site when the stumble button is pressed $max = count($urls); //Count the number of url's we have in our list $stumble = rand(0,$max); //Randomly select a url from the list require("taskbar.php"); //Load the bar at the top of the page and keep it there echo "I picked $urls[$stumble]"; //Just an example to show what was picked. echo "<br /><br /><iframe frameborder='0' noresize='noresize' style='position: absolute; background: transparent; width: 100%; height:100%;' src='$urls[$stumble]' />This Site uses iFrames</iframe>"; //Loads the site contents } ?> ?> //FILE: taskbar.php <div align="center"><a href="?do=stumble" />Stumble</a></div><br /><br /> i would not recommend using the above code as it's open for attack but hopefully it will help you to understand how php can achieve what you are after, You could use ajax to load the pages but it's more of a fancy effect, Hope it helps Stuie Quote Link to comment https://forums.phpfreaks.com/topic/165756-creating-a-website-like-stumbleupon/#findComment-874464 Share on other sites More sharing options...
Chamza Posted July 13, 2009 Author Share Posted July 13, 2009 Stuie_b, that was incredibly helpful! Although I don't know much PHP I can decipher most of it through my past programming experiences. Thank you so much, if anyone has anything additional to add I'd be more than grateful. Quote Link to comment https://forums.phpfreaks.com/topic/165756-creating-a-website-like-stumbleupon/#findComment-874853 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.