Jump to content

Implementing MySQL


Chamza

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/194568-implementing-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.