Current location: Hot Scripts Forums » Programming Languages » PHP » Random script issues


Random script issues

Reply
  #1 (permalink)  
Old 01-10-04, 07:57 AM
Delusion Delusion is offline
New Member
 
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Random script issues

Hello,

Generally, I'll describe what was my idea at first.

I've been trying to make a script for my school (football, 1vs1) that will make me random teams selection.

The main idea about it, I got 11 teams, The random I was trying to do:

Each team should play 20 games in a season, with each team playing each other TWICE at a season.

I've tried to make this using a 'FOR' loops but I've got double games and alot of mess.

Here's my try:
PHP Code:

<?

echo "<table>";
 for(
$i=$c=$b=$a=$i <= 220 $i++ , $c+=$b++, $a++) {

   echo 
"<tr>";
     echo 
"<td width='100' align='left'>$i</td>";
     echo 
"<td>team $a</td>";
     echo 
"<td>vs.</td>";
     echo 
"<td>team $b</td>";
   echo 
"</tr>";

  
// Storing the DATA at MySQL irrelevant now

   
if ($a >= "11") { $a "0"; }
   if (
$b >= "11") { $b "0"; }
   if (
$c >= "6") { $c "0"; echo "<tr><td colspan='5'><hr></td></tr>"; }
 }

echo 
"</table>";
I've spent alot of time trying to make it work and failed
I hope someone around will be able helping me!

Thanks in advnace.
Reply With Quote
  #2 (permalink)  
Old 01-10-04, 09:39 AM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Could you not just use rand()? from 1 to 11?

PHP Code:

<?

echo rand(111);
?>
Edit: Nvm, bad idea :S did not see how exactually you want it to be displayed.

Last edited by Infinite_Hackers; 01-10-04 at 09:50 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching for a random quote free script... Sgrebs Script Requests 4 03-11-06 09:09 PM
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM
picking random entries with a filter... Double selection problem dsumpter PHP 7 11-16-03 07:19 PM
Searching for a random quote free script... Sgrebs Script Requests 0 11-14-03 02:44 PM
looking for a random number script ncben Script Requests 3 08-07-03 09:10 AM


All times are GMT -5. The time now is 08:25 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.