firist

firist

  • NA
  • 1
  • 1.4k

Homepage? database?

Nov 12 2012 8:40 AM
Hello,
I wanted to create a script that generate 1 of 3 random links.
But each link should be output only 1 time.
At the moment I have the followring script:

<script type='text/javascript'>
<!--
var a=i=0;
var spruch = new Array();

spruch[i++] = "http://www.link-1.com";
spruch[i++] = "http://www.link-2.com";
spruch[i++] = "http://www.link-3.com";

function ateball() {
a = Math.random();
b = a * spruch.length;
var rand_url = document.getElementById('zufianwser').innerHTML=spruch[Math.round(b)];
document.write('<a href="' + rand_url + '">' + rand_url + '</a>');
document.getElementById('zufibutton').value="Create a new Link";
}
//-->
</script> <input type="button" onclick="ateball()" id="zufibutton" name="zufibutton" value="Create a Link" /><br />
<div id="zufianwser">Klick the Button to get a Link</div>


If somebody click on the Button a random Link will be shown.
Then the script have to create a new row the the name of the link as value.
If somebody else click on the button the script have create a random link, that won't be exist in the database.
If all 3 Links exist in the database, the script have to write "ERROR".
But I don't know, How I can use a database on it!