Chamza Posted March 9, 2010 Share Posted March 9, 2010 Hello all, I am trying to make a website like StumbleUpon.com. 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. Here is the PHP code I have so far, and right now, its functional: //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 } ?> ?> As you can see, the code is really primitive, but what I ultimately want to do is have a wide variety of databases that store many many links. Clearly, the php "array" wont cut it once I have more than two links, Im going to need a database of links in mySQL that I can call upon to get a random link. The problem is, however, that I know virtually nothing about mySQL. So what my question eventually boils down to is: 1) How do I create different databases in MySQL that store a bunch of different links? And once I do this, how do I intertwine that with the PHP code I have above? Thank you guys, I appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/194568-implementing-mysql/ Share on other sites More sharing options...
Kryptix Posted March 9, 2010 Share Posted March 9, 2010 If you download TeamViewer I'll do this remotely for you so you can watch and learn but it's far too much to explain if you have never even used MySQL before. My MSN is: luke@xa0s.com Quote Link to comment https://forums.phpfreaks.com/topic/194568-implementing-mysql/#findComment-1023290 Share on other sites More sharing options...
gizmola Posted March 9, 2010 Share Posted March 9, 2010 A design that would work fine is very similar to what I described in this thread. You might be able to adapt the idea to your stumbleupon clone. Quote Link to comment https://forums.phpfreaks.com/topic/194568-implementing-mysql/#findComment-1023312 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.