Folks,
In my quest to learn PHP, I have came across something I could find rather useful! Basically I could do with finding out how (in php) I could create a 'program' where you put in a load of values and then press a button and it will pick one of those values and display it.
Or the reason I want it is I want a 'program' which would pick one different football team (from a list) and display it on the screen, each time I pressed a button.
Do you get me? Look forward to your response!
Random Generator
Started by theJapster, Jul 09 2006 09:36 AM
4 replies to this topic
#1
Posted 09 July 2006 - 09:36 AM
#2
Posted 09 July 2006 - 10:13 AM
You seems to be mixing net scripting and desktop programming, do you want a script which displays a new team each time you press a button on a website?
#3
Posted 09 July 2006 - 12:11 PM
This could actually be done in nothing but PHP rather easily. Of course, having some HTML to display this so called "button" would help, but that's beside the point.
There are tons of tutorials on how to do this in the tutorial database here, more often then not, they are for random affiliates, but it's all the same thing.
There are tons of tutorials on how to do this in the tutorial database here, more often then not, they are for random affiliates, but it's all the same thing.
#4
Posted 09 July 2006 - 12:33 PM
ok...here is the most basic version of what you want just to start you off.
Shouldn't be anything there you cant figure out. If there is, post back
<?php
/* These are the teams: */
$team[] = 'team1';
$team[] = 'team2';
/* To add more use this:
@
@ $team[] = 'team name';
@
*/
if(isset($_POST['press']))
{
echo $team[array_rand($team, 1)]; // '1' is the amount of teams you want.
}
else
{
echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
<input type="submit" name="press" value="Press me!" />
</form>';
}
?>
Shouldn't be anything there you cant figure out. If there is, post back
Edited by .Matt, 09 July 2006 - 12:46 PM.
#5
Posted 09 July 2006 - 12:44 PM
Thanks Matt, that does the job fantastically!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
