Jump to content

smproph

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Posts posted by smproph

  1. I've modified to this

     

    $array = $teamname;
    $k=1;
    $x=1;

     

    $line[$i] = '<td><input type=button class="team" onclick="win(this)" value="' . $array[($i-1)/2] . '">name="WIN0_'.($k).'"</td>';
    $k++;

     

    and this

    $line[$i] .= '<td><input type=button class="team" onclick="win(this)" value="">name="WIN1_'.($y+1).'"</td>';
    				$y=$x;

     

    Problem is it starts to repeat itself into future rounds. First round works perfect, second

    ss.jpg

     

     

     

  2. I added it and wrote it like this

    	$teams=$_POST['teams'];
    		$schedule=$_POST['schedule'];
    		$teamname = unserialize(urldecode($_POST["teamname"]));
    		$games=$_POST['games'];
    		$times=$_POST['times'];
    		$numofteams=(count($teamname)/2);

     

    Simon yours works perfect other than the fact I am trying to implement it to those <tr><td> because it makes it where you can click on the winner and it automatically advances them to the next bracket. It connects to my javascript I wrote thats in my first post.

     

  3. I wrote this:

    $i=1;
    $j=1;
    $k=1;
    $run=1;
    $run2=0;
    while($run<=$numofteams)
    {
    $name="WIN0_'".$i."'";
    echo'<tr>
        <td><input type=button class="team" name="'.$name.'" onclick="win(this)" value="'.$teamname[$run].'"></td>
    </tr>';
    $run++;
    
    	if($run==2)
    	{
    		$name2="WIN1_'".$j."'";
    		echo '<tr>
       					 <td></td>
       						 <td><input type=button class="team" name="'.$name2.'" onclick="win(this)" value=""></td>
    				</tr>';
    
    					if($run2==2)
    							{
    						$name3="WIN'".$k."'_1";
    								echo '<tr>
       										 <td></td>
       											 <td><input type=button class="team" name="'.$name3.'" onclick="win(this)" value=""></td>
    										</tr>';
    										$run2=0;
    										$k++;
    							}
    				$run=0;
    				$run2++;
    				$j++;
    	}
    
    $i++;
    }

     

    It almost gets it but just repeats 10,000 times and only fills in team 1 and team 2

     

  4. Well right now, since I have only entered 4 teams in, it has Team 1 Team 2 Team 3 Team 4 as my array

     

    Array ( [0] => team1 [1] => team2 [2] => team3 [3] => team4 )

     

    Not sure if I understood what you meant when you said

    Are you wanting to generate fixtures for the teams, or just display fixtures according to a particular order?

     

    I have it where you type in the teams in order by their seeds. So team1 is Seed #1, Team 2 is Seed #2 and so on... I am trying to get it to where it sees how many teams you put in, maybe with a count function on the array and then put them against each other, Seed 1 vs Seed 8.

     

    Does that make any sense?

  5. I have it to where it groups two parts of the Array randomly but I need to make it where it won't pair the same together, or if it has already been paired with a team then use another team. Each value of the array can only be used once.

     

    Here is my code

    shuffle($teamname);
    
    $loopCount = $games;
    
    for ($i = 0; $i < $loopCount; $i++) {
        $player1 = array_pop($teamname);
        $player2 = array_pop($teamname);
    if(is_null($player1))
    {
    	echo 'Not enough different teams to create '.$games.' games';
    	break;
    }
        // output to screen
        echo "Team: " . $player1 . " Vs Team: " . $player2 . "<br />"; 
    
    }
    	}

     

  6. Okay right now I have a form that pulls all the values I need and sends it to a separate page, except here is where I run into the problem. I logically have no idea who to write it. I have an array called $teamname that holds all the team names. What I need to do is make it dynamically create the table rows according to how many teams their are and then put the teams against each other like 1v8, 2v7. Here is my script that allows the bracket to work, I just need to convert it to dynamically work

    <script>
    function win(winner)
    {
        var team = winner.value;
        var levels = winner.name.substring(3).split("_");
        var curlevel = parseInt(levels[0]);
        var curgame  = parseInt(levels[1]);
    
        var nextlevel = curlevel + 1;
        var nextgame  = Math.floor( (curgame+1) / 2 );
        
        var winnerButton = winner.form.elements["WIN"+nextlevel+"_"+nextgame];
        if ( winnerButton == null ) return;
    
        ++nextlevel;
        nextgame  = Math.floor( (nextgame+1) / 2 );
        var nextButton = winner.form.elements["WIN"+nextlevel+"_"+nextgame];
        var forward = ( nextButton != null && nextButton.value == winnerButton.value );
    
        winnerButton.value = team;
        if ( forward ) winnerButton.click( );
    }
    </script>
    
    <?php
    $schedule=$_POST['schedule'];
    
    if($schedule=="season")
    	{
    		$teams=$_POST['teams'];
    		$schedule=$_POST['schedule'];
    		$teamname = unserialize(urldecode($_POST["teamname"])); 
    		$games=$_POST['games'];
    		$times=$_POST['times'];
    
    	}
    if($schedule=="playoffs")
    	{
    		$teams=$_POST['teams'];
    		$schedule=$_POST['schedule'];
    		$teamname = unserialize(urldecode($_POST["teamname"]));
    		$games=$_POST['games'];
    		$times=$_POST['times'];
    		$result = count($teamname);
    
    ?>
    <form>
    <table border=0 cellpadding=3>
    <tr>
        <td><input type=button class="team" name="WIN0_1" onclick="win(this)" value="Amherst"></td>
    </tr>
    <tr>
        <td></td>
        <td><input type=button class="team" name="WIN1_1" onclick="win(this)" value=""></td>
    
    </tr>
    <tr>
        <td><input type=button class="team" name="WIN0_2" onclick="win(this)" value="Bowling Green"></td>
    </tr>
    <tr>
        <td> </td>
        <td> </td>
        <td><input type=button class="team" name="WIN2_1" onclick="win(this)" value=""></td>
    </tr>
    <tr>
        <td><input type=button class="team" name="WIN0_3" onclick="win(this)" value="Connecticut"></td>
    </tr>
    <tr>
        <td></td>
        <td><input type=button class="team" name="WIN1_2" onclick="win(this)" value=""></td>
    </tr>
    <tr>
        <td><input type=button class="team" name="WIN0_4" onclick="win(this)" value="Duke"></td>
    </tr>
    <tr>
        <td> </td>
        <td> </td>
        <td> </td>
        <td><input type=button class="team" name="WIN3_1" onclick="win(this)" value=""></td>
    </tr>
    <tr>
        <td><input type=button class="team" name="WIN0_5" onclick="win(this)" value="Elmira"></td>
    </tr>
    <tr>
        <td></td>
        <td><input type=button class="team" name="WIN1_3" onclick="win(this)" value=""></td>
    
    </tr>
    <tr>
        <td><input type=button class="team" name="WIN0_6" onclick="win(this)" value="Florida"></td>
    </tr>
    <tr>
        <td> </td>
        <td> </td>
        <td><input type=button class="team" name="WIN2_2" onclick="win(this)" value=""></td>
    </tr>
    <tr>
        <td><input type=button class="team" name="WIN0_7" onclick="win(this)" value="Georgetown"></td>
    </tr>
    <tr>
        <td></td>
        <td><input type=button class="team" name="WIN1_4" onclick="win(this)" value=""></td>
    </tr>
    <tr>
        <td><input type=button class="team" name="WIN0_8" onclick="win(this)" value="Hawaii"></td>
    </tr>
    
    </table>
    </form>
    <?
    	}
    	?>

     

  7. I seem to be losing my array value when it comes to the "Game Time" section of my script. I am printing out the array a long the entire time and this is where I lose it and can't figure out why.

    <form name="form1" method="post" action="">
    <span class="whitetitle">How many teams?</span>
    	<ul class="pageitem">
                <li>
    				<SELECT name="teams"  onchange="document.form1.submit();">
                		<option value="1">1</option>
                       <option value="2">2</option>
                       <option value="3">3</option>
                       <option value="4">4</option>
                       <option value="5">5</option>
                       <option value="6">6</option>
                       <option value="7">7</option>
                       <option value="8">8</option> 
                       <option value="9">9</option>
                       <option value="10">10</option>
                       <option value="11">11</option>
                       <option value="12">12</option>
                	</SELECT>
                    </li>
                    </ul>
                    </form>
            <?
    if($_POST['teams'])
    {
    ?>
    <form  method="post" name="form2" action="">
    <span class="whitetitle">Team Name</span>
    <?php
    $teams=$_POST['teams'];
    $count=0;
      while($count<$teams)
      {
      ?>
    	<ul class="pageitem">
    		<li class="bigfield">
                <input placeholder="Name" type="text" name="teamname[]"/>
                </li>
               </ul>
             <?
    	 $count++;
    	 }
    	 ?> 
             <input type="hidden" value="<?=$teams?>" name="teams" />
              <input type="submit" name="Submit" value="Next"> 
    </form>    
    <?
    }
    ?>
            <?
    	if ($_POST['teamname'])
    	{
    		$teams=$_POST['teams'];
    		$teamname=$_POST['teamname'];
    	?>
            <form name="form" method="post" action="">
              <span class="name"><? print_r ($_POST['teamname']);?></span>
          	<ul class="pageitem">
    		<li class="radiobutton"><span class="name">Season</span>
    		<input name="schedule" type="radio" value="season" onClick="this.form.action='';this.form.submit()" /></li>
    		<li class="radiobutton"><span class="name">Playoffs</span>
    		<input name="schedule" type="radio" value="playoffs" onClick="this.form.action='';this.form.submit()"/></li>
    	</ul>
            <input type="hidden" value="<?=$teams?>" name="teams" />
            <input type="hidden" value="<?=$teamname?>" name="teamname" />
            </form>
            <?
    	}
    	if($_POST['schedule'])
    	{
    		$teams=$_POST['teams'];
    		$schedule=$_POST['schedule'];
    		$teamname=$_POST['teamname'];
    	?>
            <form name="form4" method="post" action="">
             <span class="name"><? print_r ($_POST['teamname']);?></span>
            <span class="whitetitle">Games per Night</span>
    	<ul class="pageitem">
                <li>
    				<SELECT name="games" onchange="document.form4.submit();">
                		<option value="1">1</option>
                       <option value="2">2</option>
                       <option value="3">3</option>
                       <option value="4">4</option>
                       <option value="5">5</option>
                       <option value="6">6</option>
                       <option value="7">7</option>
                       <option value="8">8</option> 
                       <option value="9">9</option>
                       <option value="10">10</option>
                       <option value="11">11</option>
                       <option value="12">12</option>
                	</SELECT>
                    </li>
                    </ul>
                    <input type="hidden" value="<?=$teamname?>" name="teamname" />
                    <input type="hidden" value="<?=$teams?>" name="teams" />
                    <input type="hidden" value="<?=$schedule?>" name="schedule" />
                    </form>
                 <?
    	}
    	if($_POST['games'])
    	{
    		$teams=$_POST['teams'];
    		$schedule=$_POST['schedule'];
    		$games=$_POST['games'];
    		$teamname=$_POST['teamname'];
    		$count=0;
    		 ?>
                    <form name="form5" method="post" action="">
                      <span class="name"><? print_r ($_POST['teamname']);?></span>
                 <span class="whitetitle">Times</span>
    	<ul class="pageitem">
            <?
    	while($count<$games)
    	{
    	?>
                <li>
    			<input placeholder="Times" type="text" name="times[]"/>
                    </li>
              <?
    	  $count++;
    	}
    	  ?>
                    </ul>
                     <input type="hidden" value="<?=$teamname?>" name="teamname" />
                     <input type="hidden" value="<?=$teams?>" name="teams" />
                    <input type="hidden" value="<?=$schedule?>" name="schedule" />
                    <input type="hidden" value="<?=$games?>" name="games" />
                    <input type="submit" name="Submit" value="Next">
    			</form>
    <?
    	}
    	if($_POST['times'])
    	{
    
    		echo $_POST['teams'];
    		print_r ($_POST['teamname']);
    		echo $_POST['schedule'];
    		echo $_POST['games'];
    		echo implode(",",$_POST['times']);
    	}
    ?>

     

  8. Hmm seem to be getting a problem. It spits out this error:

     

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AAA'),('Eric'AAA'),('Joe','AAA')' at line 2

     

    AAA is the Team name. It looks like to me maybe the " ' " are canceling out somewhere.

    ('Eric'AAA') has 3 " ' " while ('Joe','AAA') has 4 " ' ".

     

    And Ideas?

  9. Ok I have a form where on of the inputs looks like this

     

     <input placeholder="Name" type="text" name="participant_name[]"/>

     

    Have to use that as array because I have a while loop that creates that input according to how many players they choose to be on their team.

     

    I need to be able to insert every participant_name into the participant field of my table. I was reading that maybe I need to do Implode or Explode, I'm not quite sure.

     

    If you want to see the form in action or look at it url is : http://snu.uintramural.com/form.php?mode=team

     

    Here's my php.

                 	$sql2="INSERT INTO teams (team_no,team_password) VALUES ( '$_POST[team]','$_POST[pw]')";
    			$result2=mysql_query($sql2) or die(mysql_error());
    			  
                    $sql="INSERT INTO participants (participant_name, team_no)
    			VALUES
    			('$_POST[participant_name]','$_POST[team]')";
    
    
    
                //echo $sql; 
              $result=mysql_query($sql) or die(mysql_error());

     

     

     

  10. I made a simple form and a table. Well for some reason Firefox is lining two of my rows next to each other but Safari puts the row below each other like it should be and I can't figure out if its a firefox thing or my code. Here it is

    <form action="" method="post" name="question"> 
    <table>
    <tr>
    <td>Do you have Children</td>
    </tr>
    <tr>
    <td>Yes
    <input name="children" type="radio" value="yes"  onclick = "if(document.getElementById('children').style.display=='none') 
           {
           document.getElementById('children').style.display='inline';
           document.getElementById('children2').style.display='inline';
           } " />
    
        No
    <input name="children" type="radio" value="no"   onclick = "if (document.getElementById('children').style.display='inline') 
           {
           document.getElementById('children').style.display='none';
           document.getElementById('children2').style.display='none';
           } " />
    </td>
    </tr> 
    
    <tr id="children" style="display:none;">
    <td>Name<br/><input type="text" name="name" /></td>
    <td>DOB<br/><input type="text" name="dob" /></td>
    <td>Age<br/><input type="text" name="age" /></td>
    </tr>
    <tr id="children2" style="display:none;">
    <td>Social<br/><input type="text" name="social" /></td>
    <td>DL<br/><input type="text" name="dl" /></td>
    </tr>
    <tr>
    	<td>Do you have pets</td>
    </tr>
    <tr>
    <td>Yes<input name="pets" type="radio" value="yes"  onclick = "if(document.getElementById('pet').style.display=='none') 
           {
           document.getElementById('pet').style.display='inline';
           } " />
    
    No
    <input name="pets" type="radio" value="no"   onclick = "if (document.getElementById('pet').style.display='inline') 
           {
           document.getElementById('pet').style.display='none';
           } " />
           </td>
    </tr>
    <tr id="pet" style="display:none;">
    <td>Name<br/><input type="text" name="name" /></td>
    <td>Type<br/><input type="text" name="dob" /></td>
    <td>Age<br/><input type="text" name="age" /></td>
    </tr>
    <tr>
    <td><input type="submit" name="submit" value="Submit"></td>
    </tr>
    </table>
    </form>

     

  11. I've changed it to:

    if($_POST['Initials']) 
    { 
       $Initials=$_POST['Initials'];  
       $qry_str.=" and Initials LIKE '%{$Initials}%'"; 
    } 
    
    if($_POST['Identifier']) 
    { 
       $Identifier=$_POST['Identifier'];  
       $qry_str.=" and Identifier LIKE '%{$Identifier}%'"; 
    } 
    
    if($_POST['Type']) 
    { 
       $Type=$_POST['Type'];  
       $qry_str.=" and Type LIKE '%{$Type}%'"; 
    } 
    if($_POST['Terms']) 
    { 
       $Terms=$_POST['Terms'];  
       $qry_str.=" and Terms LIKE '%{$Terms}%'"; 
    } 
    if($_POST['Memo']) 
    { 
       $Memo=$_POST['Memo'];  
       $qry_str.=" and Memo LIKE'%{$Memo}%'"; 
    }
    if($_POST['date1']) 
    {  
       $date1=$_POST['date1'];
       $date2=$_POST['date2'];
       $start=date('Y-m-d', strtotime($date1));
       $end=date('Y-m-d', strtotime($date2));
       $qry_str.=" and Date >= $start and Date <= $end "; 
    }
    if($_POST['order1'] && $_POST['order2'])
    {
    $order1=$_POST['order1'];
    $order2=$_POST['order2'];
    $qry_str=$_POST['qry'];
    $qry_str=" '{$qry_str}' ORDER BY '{$order1}' ASC, '{$order2}' ASC ";
    }

     

    I am getting this as an error:

     

    Query string: 'SELECT * FROM timeslip WHERE 1 and Initials LIKE ''%GEC%'' and Type LIKE ''%IPC%'' and Terms LIKE ''%HRT%''' ORDER BY 'Date' ASC, 'Cost' ASC

    Failed with error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''SELECT * FROM timeslip WHERE 1 and Initials LIKE ''%GEC%'' and Type LIKE ''%IPC' at line 1

     

    I can see already right before ORDER BY there are 3 '''. Not sure why it is adding them. I am not sure if it is doubling the " ' " or not.

     

  12. Well I changed some of the IF statements and I am getting this

     

    Query string: SELECT * FROM timeslip WHERE 1 and Initials LIKE ''%GEC%'' and Type LIKE ''%IPC%'' and Terms LIKE ''%HRT%'' ORDER BY "Date" ASC, "Cost" ASC

    Failed with error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%GEC%'' and Type LIKE ''%IPC%'' and Terms LIKE ''%HRT%'' ORDER BY "Date" ASC, "C' at line 1

     

    It is showing the Initials. It's just the " ' " are killing me some how

  13. It is in the 2nd window of code

    SELECT NAME=Initials>
    <OPTION value="">Select</OPTION>
              		<OPTION value="AAC">AAC</OPTION>
                    <OPTION value="AJP">AJP</OPTION>
                	<OPTION value="EJG">EJG</OPTION>
                    <OPTION value="FAH">FAH</OPTION>
                	<OPTION value="GEC">GEC</OPTION>
                   <OPTION value="IJC">IJC</OPTION> 
                   <OPTION value="KHW">KHW</OPTION> 
                   <OPTION value="LH">LH</OPTION> 
                   <OPTION value="VRT">VRT</OPTION>
                </SELECT>

     

    I have gotten to the point too where it does have the variable and all the information. It is just that the MYSQL syntax is canceling it out. It has something to do with my Quotes. Can't seem to figure out a clean way to write it to where it is not canceling out

     

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