Jump to content

chriscloyd

Members
  • Posts

    488
  • Joined

  • Last visited

Posts posted by chriscloyd

  1. ya i think i am so how do i get out haha i update my script and it schedules it but it still comes up with the error

     

    class scheduler

    <?php
    class scheduler {
    
    var $week;
    var $max_teams;
    
    function scheduler() {
    	global $Settings;
    	$get_all = mysql_query("SELECT * FROM teams");
    	$this->max_teams = mysql_num_rows($get_all);
    	if ($Settings->week == 'Not Started') {
    		$this->week = 1;
    	} else {
    		$this->week = $Settings->week;
    	}
    }
    function CheckTeams($team1,$team2) {
    	//check if the two teams have played at all
    	//this season
    	if ($team1 == $team2) {
    		return false;
    	}
    	if ($this->checkPlay($team1,$team2)) {
    		return true;
    	} else {
    		return false;
    	}		
    }
    function checkTeam ($team) {
    	$check = mysql_query("SELECT * FROM matches WHERE team1 = '".$team."' OR team2 = '".$team."' AND week = '".$this->week."'");
    	$num = mysql_num_rows($check);
    	if ($num > 0) {
    		return false;
    	} else {
    		return true;
    	}
    }
    function checkPlay ($team1,$team2) {
    	$week = $this->week;
    	$check = mysql_query("SELECT * FROM matches WHERE team1 = '".$team1."' AND team2 = '".$team2."' OR  team1 = '".$team2."' AND team2 = '".$team1."'");
    	$num = mysql_num_rows($check);
    	if ($num > 0) {
    		return false;
    	} else {
    		return true;
    	}
    }
    function createMatch ($team1,$team2) {
    	$week = $this->week;
    	$create = mysql_query("INSERT INTO matches (`team1`, `team2`, `week`) VALUES ('$team1','$team2', '$week')");
    	if ($create) {
    		return true;
    	} else {
    		return false;
    	}
    }
    }
    ?>	
    

     

    the index page to schedule and show results

     

    <?PHP
    session_start();
    mysql_connect('localhost',******,******);
    mysql_select_db(******);
    include("classes/settings.php");
    include("classes/scheduler.php");
    $Scheduler = new scheduler;
    
    //set arrarys
    $available = array();
    $playing = array();
    
    //get all teams first and set them in available array
    $get_all = mysql_query("SELECT * FROM teams");
    $max_teams = mysql_num_rows($get_all);
    $i = 1;
    $rand_team = rand(1,$max_teams);
    while($team = mysql_fetch_assoc($get_all)) {
    $available[$i] = 	$team['teamname'];
    $i++;
    }
    // end getting all teams
    for ($i = 1; $i < $Scheduler->max_teams; $i++) {
    //get the two teams
    $get_team1 = rand(1,$Scheduler->max_teams);
    $get_team2 = rand(1,$Scheduler->max_teams);
    $team1 = $available[$get_team1];
    $team2 = $available[$get_team2];
    if ($Scheduler->checkTeam($team1)) {
    	if ($Scheduler->checkTeam($team2)) {
    		if ($Scheduler->CheckTeams($team1,$team2)) {
    			if ($Scheduler->createMatch($team1,$team2)) {
    				echo 'Scheduled '.$team1.' to play '.$team2.' in week '.$Scheduler->week.'<br />';
    				;
    			} else {
    				$i--;
    			}
    		} else {
    			$i--;
    		}
    	} else {
    		$i--;
    	}
    } else {
    	$i--;
    }	
    }
    
    ?>
    

  2. Need help the page doesnt do anything, if anyone could guide me in helping me make this work and more efficient

    I am making a weekley scheduler

    if the team have either played this week dont schedule

    or if the two teams have played each other in previous weeks dont schedule them together

    here is my scheduler class

    <?php
    class scheduler {
    
    var $week;
    var $max_teams;
    
    function scheduler() {
    	global $Settings;
    	$get_all = mysql_query("SELECT * FROM teams");
    	$this->max_teams = mysql_num_rows($get_all);
    	if ($Settings->week == 'Not Started') {
    		$this->week = 1;
    	} else {
    		$this->week = $Settings->week;
    	}
    }
    function CheckTeams($team1,$team2) {
    	//check if the two teams have played at all
    	//this season
    	if ($this->checkPlay($team1,$team2)) {
    		return true;
    	} else {
    		return false;
    	}		
    }
    function checkPlay ($team1,$team2) {
    	$week = $this->week;
    	$check = mysql_query("SELECT * FROM matches WHERE team1 = '".$team1."' AND team2 = '".$team2."' OR  team1 = '".$team2."' AND team2 = '".$team1."'");
    	$num = mysql_num_rows($check);
    	if ($num > 0) {
    		return false;
    	} else {
    		$check = mysql_query("SELECT * FROM matches WHERE `team1` = '".$team1."' OR `team2` = '".$team1."' AND `week` = '".$week."' ");
    		$nums = mysql_num_rows($check);
    		if ($nums > 0) {
    			return false;
    		} else {
    			$check = mysql_query("SELECT * FROM matches WHERE `team1` = '".$team2."' OR `team2` = '".$team2."' AND `week` = '".$week."' ");
    			$nums = mysql_num_rows($check);
    			if ($nums > 0) {
    				return false;
    			} else {
    				return true;
    			}
    		}
    	}
    }
    function createMatch ($team1,$team2) {
    	$create = mysql_query("INSERT INTO matches (`team1`, `team2`) VALUES ('$team1','$team2')");
    	if ($create) {
    		return true;
    	} else {
    		return false;
    	}
    }
    }
    ?>

     

    here is my other script

    <?php
    
    //get all teams first and set them in available array
    $get_all = mysql_query("SELECT * FROM teams");
    $max_teams = mysql_num_rows($get_all);
    $i = 1;
    $rand_team = rand(1,$max_teams);
    while($team = mysql_fetch_assoc($get_all)) {
    $available[$i] = 	$team['teamname'];
    $i++;
    }
    
    // end getting all teams
    for ($i = 1; $i < $Scheduler->max_teams; $i++) {
    //get the two teams
    $get_team1 = rand(1,$Scheduler->max_teams);
    $get_team2 = rand(1,$Scheduler->max_teams);
    $team1 = $available[$get_team1];
    $team2 = $available[$get_team2];
    if ($Scheduler->CheckTeams($team1,$team2)) {
    	if ($Scheduler->createMatch($team1,$team2)) {
    		echo 'Scheduled '.$team1.' to play '.$team2.' in week '.$Scheduler->week.'<br />';
    	}
    }else {
    	$i--;
    }
    
    
    }
    
    ?>

  3. I have coded my forums and they work well, but now I need some help.

    I am trying to do the sorta thing that most forums do.  When you leave and come back to the forums

    it shows you which forums or posts have been updated or added by a new color image.

    Can someone lead me in the way to do it and I can code it out from there.  I just cant logically get how it works.

  4. i have a script im working on to make a schedule

    i have it go into the database to see if its matched up with the team that the random generator picked

    if it is the function is returned false

    how can i rerun that function till it gets one that hasnt been used

  5. Well I have this script and the name one is working but the email one isnt working :(  can someone help me

     

    window.onload = initpage;
    
    function initpage () {
            document.getElementById("name").onblur = checkname;
    document.getElementById("nlemail").onblur = checknlemail;
    }
    function checkname() {
    var name = document.getElementById("name").value;
    if (name == '') {
    	document.getElementById("name_hidden").innerHTML = 'Please enter your name.';
    } 
    else {
    	document.getElementById("name_hidden").innerHTML = '';
    }
    }
    function checknlemail() {
    var email = document.getElementById("nlemail").value;
    document.getElementById("email_hidden").innerHTML = 'TEST';
    }

     

    that was my ajax now my html

    is

    <form id="newsletter" name="newsletter" method="post" action="">
      <input name="nlemail" type="text" id="nlemail" value="Email" />
      <div id="email_hidden"></div>
      <input name="name" type="text" id="name" />
      <div id="name_hidden"></div>
    </form>

  6. well u want to query all your users

    <?php

    //mysql connect info should be added

    $get_users = mysql_query("GET * FROM users")

    while ($users = mysql_fetch_array($get_users)) {

          $subject = "new post in [forum name]";

          $to = $user['email'];

          $message = 'new post check it out blah blah blah';

          mail ('$to','$subject','$message');

    }

     

  7. i have this code below and nothing shows up not even the else statements

    <?php
    error_reporting(E_ALL);
    $connect = mysql_connect("localhost","**********","**********") or die(mysql_error());
    if ($connect) {
    $select = mysql_select_db("site") or die(mysql_error());
    	if ($select) {
    	$test = mysql_query("INSERT INTO `site`.`quotes` (`id`, `name`, `email`, `phone`, `type`, `budget`, `start`, `info`, `ip`, `time`) VALUES (NULL, \'1\', \'1\', \'1\', \'1\', \'1\', \'1\', \'1\', \'1\', \'1\')" or die(mysql_error());
    	if($test) {
    		echo 'yes';
    	} else {
    		echo 'no';
    	}
    } else {
    	echo "couldnt find db";
    }
    } else {
    echo "couldnt find server";
    }
    ?>

  8. can u show me the html code really quick for the links

    for example you can do this depending where ur link is

     

    <div id="menu"><a href="#">Link Here</a></div>

     

    css

     

    #menu a {

        background-color:blue;

        display:block;

        padding:5px;

    }

    #menu a:hover {

        background-color:white;

        display:block;

        padding:5px;

    }

×
×
  • 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.