Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.55 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. PHP / MYSQL random football timetable
  2. <?php
  3. mysql_query("INSERT INTO timetable (id, team1, team2, date, time) VALUES ('','Blue','Red','2011-02-06','18.00')")
  4. ?>
  5.        
  6. <?php
  7. $teams = array('Red Team', 'Blue Team', 'Yellow Team', 'Green Team');
  8. foreach($teams as $team_one) {
  9.   foreach($teams as $team_two) {
  10.     mysql_query("INSERT INTO timetable (team1, team2) VALUES ('$team_one', '$team_two')");
  11.   }
  12. }
  13. ?>
  14.        
  15. mysql_query("INSERT INTO timetable (team1, team2) VALUES ('".mysql_real_escape_string($team_one)."', '".mysql_real_escape_string($team_two)."')");