Jump to content

Order (sort) by


miniu

Recommended Posts

Hi How can make it that the table will shown sort by: 1. Date, 2. Division Code. ?

 

this is the code for that:

 <form name="form1" method="post" action="">
	    <table width="100%" cellpadding="2" cellspacing="0" class="t-a">
              
              <tr>
                <td height="42" colspan="9" class="H4">Assign Referee to A Game                </td>
              </tr>
              <tr>
                <td width="6%" height="27" class="th-a">League </td>
                <td width="6%" class="th-a">Division</td>
                <td width="10%" class="th-a">Home Team</td>
                <td width="9%" class="th-a">Away Team</td>
                <td width="8%" class="th-a">Date of Game</td>
                <td width="6%" class="th-a"> Time</td>
                <td width="11%" class="th-a">Location Name</td>
                <td width="13%" class="th-a">Location Address</td>
                <td width="31%" class="th-a">Referees</td>
              </tr>
		<?
		while($row_games=mysql_fetch_object($rs_games))
		{
			$league=getLeague($row_games->league_id);

			$leaguecode=$league->league_code;
			$leaguename=$league->league_name;
			$leagueaddress=$league->address;

			$division=getDivision($row_games->div_id);

			$divisioncode=$division->dcode;
			$divisionname=$division->dname;
			$MainRefereeFee=$division->mainref_fee;
			$AstRefereeFee=$division->astref_fee;

			$HomeTeam=getTeam($row_games->home_team_id);

			$HomeTeamName=$HomeTeam->tname;
			$HomeTeamManager=$HomeTeam->htmanager;
			$HomeTeamPhone=$HomeTeam->phone;		

			$AwayTeam=getTeam($row_games->away_team_id);

			$AwayTeamName=$AwayTeam->tname;

			$txtgdate=$row_games->gdate;
			$txtgdate_arr=explode("-",$txtgdate);
			$txtgdate=$txtgdate_arr[1].'-'.$txtgdate_arr[2].'-'.$txtgdate_arr[0];

			$txtgtime=$row_games->gtime;
			$txtgtime_arr=explode("-",$txtgtime);
			$txtgtime=$txtgtime_arr[1].''.$txtgtime_arr[2].''.$txtgtime_arr[0];

			$row_location=getLocation($row_games->location_id);

			$loc_name=$row_location->lname;
			$loc_address=$row_location->address;

			$max++;

			print('<tr>
					<td>'.$leaguecode.'<input type="hidden" id="leaname'.$max.'" name="leaname'.$max.'" value="'.$leaguename.'"><input type="hidden" id="league_address'.$max.'" name="league_address'.$max.'" value="'.$leagueaddress.'"></td>
					<td>'.$divisioncode.'<input type="hidden" id="dname'.$max.'" name="dname'.$max.'" value="'.$divisionname.'"></td>
					<td>'.$HomeTeamName.'<input type="hidden" id="htname'.$max.'" name="htname'.$max.'" value="'.$HomeTeamName.'"></td>
					<td>'.$AwayTeamName.'<input type="hidden" id="atname'.$max.'" name="atname'.$max.'" value="'.$AwayTeamName.'">
<input type="hidden" id="htmanager'.$max.'" name="htmanager'.$max.'" value="'.$HomeTeamManager.'"><input type="hidden" id="telephone'.$max.'" name="telephone'.$max.'" value="'.$HomeTeamPhone.'"></td>
					<td>'.$txtgdate.'<input type="hidden" id="gdate'.$max.'" name="gdate'.$max.'" value="'.$txtgdate.'"></td>
					<td>'.$txtgtime.'<input type="hidden" id="gtime'.$max.'" name="gtime'.$max.'" value="'.$txtgtime.'"></td>
					<td>'.$loc_name.'<input type="hidden" id="lname'.$max.'" name="lname'.$max.'" value="'.$loc_name.'"></td>
					<td>'.$loc_address.'<input type="hidden" id="address'.$max.'" name="address'.$max.'" value="'.$loc_address.'"></td>
					<td> 
						(R): '.getReferee($row_games->gdate,mainref.$max).'<input type="hidden" name="mainref_fee'.$max.'" value="'.$MainRefereeFee.'"><br>
						(AR1): '.getReferee($row_games->gdate,astref1.'_'.$max).'<input type="hidden" name="astref_fee'.$max.'" value="'.$AstRefereeFee.'"><br>
						(AR2): '.getReferee($row_games->gdate,astref2.'_'.$max).'<br>
						<input name="gid'.$max.'" type="hidden" value="'.$max.'">
					</td>
				  </tr>
				');


		}
	  ?>
          <tr>
          <td colspan="9">
            </td>
          </tr>
          <tr>
          <td colspan="9">
            <div align="center">
              <input type="hidden" name="max" id="max" value="<?=$max?>">
              <input name="Submit" type="submit" class="buttonclass" value="Submit" onClick="return kyb_check();" />
              <input type="hidden" name="sql" id="sql" value="<?=$sql_games?>">
              <input type="hidden" name="sub2" value="1">
            </div></td>
          </tr>
            </table>
          </form>

Link to comment
https://forums.phpfreaks.com/topic/196394-order-sort-by/
Share on other sites

Maybe I am putting it int he wrong place. What line should I add this order? this is the code:

<?php include("connect.php");
include("admin.session.php");
require_once("dbfunctions.php");
$LeftLinkSection = 1;
$pagetitle="A Referee To a Game";
$qstr=$_SERVER['QUERY_STRING'];

if($_REQUEST["sub2"]==1)
{

for($i=1;$i<=$_REQUEST['max'];$i++)
{
	$gid=$_REQUEST['gid'.$i.''];


$sel="select id from assigned_games where gid=".$gid;
$res_sel=mysql_query($sel);
if(mysql_num_rows($res_sel) > 0)
{
	$msg=1;
}
else
{

$main_ref_id=$_REQUEST['mainref'.$i.''];
$ast_ref_id1=$_REQUEST['astref1_'.$i.''];
$ast_ref_id2=$_REQUEST['astref2_'.$i.''];

$main_ref_fee=$_REQUEST['mainref_fee'.$i.''];
$ast_ref1_fee=$_REQUEST['astref_fee'.$i.''];
$ast_ref2_fee=$_REQUEST['astref_fee'.$i.''];

$htmanager = $_REQUEST['htmanager'.$i.''];
$telephone = $_REQUEST['telephone'.$i.''];
$reffee = $_REQUEST['reffee'.$i.''];

$dname = $_REQUEST['dname'.$i.''];
$leaname = $_REQUEST['leaname'.$i.''];
$league_address = $_REQUEST['league_address'.$i.''];
$htname = $_REQUEST['htname'.$i.''];
$atname = $_REQUEST['atname'.$i.''];
$gdate = $_REQUEST['gdate'.$i.''];
$gtime = $_REQUEST['gtime'.$i.''];
$locname = $_REQUEST['lname'.$i.''];
$address = $_REQUEST['address'.$i.''];

if($main_ref_id=='')
	$main_ref_id=0;

if($ast_ref_id1=='')
	$ast_ref_id1=0;

if($ast_ref_id2=='')
	$ast_ref_id2=0;

if($main_ref_id!=0 || $ast_ref_id1!=0 || $ast_ref_id2!=0)
{
	$sql_ins="insert into assigned_games set gid=$gid,main_ref_id=$main_ref_id,main_ref_fee='$main_ref_fee',ast_ref1_fee='$ast_ref1_fee',ast_ref2_fee='$ast_ref2_fee',ast_ref_id1=$ast_ref_id1,ast_ref_id2=$ast_ref_id2,assigner_id=".$_SESSION['UsErId']; 
	$res_ins=mysql_query($sql_ins) or die(mysql_error());
	//print('aaa<br>'.$sql_ins);
	echo mysql_error();
}
$sql_ass="select fname,lname,email,phone from assigners where username='".$_SESSION["UsErOfAdMiN"]."'";
$res_ass=mysql_query($sql_ass);
$row_ass=mysql_fetch_object($res_ass);

$fnamea=$row_ass->fname;
$lnamea=$row_ass->lname;
$phone=$row_ass->phone;

$flname=$fnamea.' '.$lnamea;

if($main_ref_id!='')
{
	$sql_mainref="select fname,lname,email from referees where id=".$main_ref_id;
$res_mainref=mysql_query($sql_mainref);
$row_mainref=mysql_fetch_object($res_mainref);

$fname=$row_mainref->fname;
$lname=$row_mainref->lname;
$email=$row_mainref->email;


$mailcontent="<html><head></head><body>
<table width='80%' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr><td colspan='2'> </td></tr>
<tr>
<td width='47%' height='56'>Dear <b>$fname $lname</b>,</td>
<td width='117' align='center' nowrap='nowrap'></td>
</tr>

<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>You have been assigned to the following game by Assigner <strong>".$flname."</strong> and and You have been selected as <strong>Main Referee</strong>:</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'><strong>League:</strong> ".stripslashes($leaname)."</td></tr>
<tr><td colspan='2'><strong>Division:</strong> ".stripslashes($dname)."</td></tr>
<tr><td colspan='2'><strong>Main Referee Fee:</strong> $$main_ref_fee</td></tr>
<tr><td colspan='2'><strong>Home Team Name:</strong> ".stripslashes($htname)."</td></tr>
<tr><td colspan='2'><strong>Away Team Name:</strong> ".stripslashes($atname)."</td></tr>
<tr><td colspan='2'><strong>Home Team Manager:</strong> ".stripslashes($htmanager)."</td></tr>
<tr><td colspan='2'><strong>Telephone:</strong> $telephone</td></tr>
<tr><td colspan='2'><strong>Game Date:</strong> $gdate</td></tr>
<tr><td colspan='2'><strong>Game Time:</strong> $gtime</td></tr>
<tr><td colspan='2'><strong>Location:</strong> ".stripslashes($locname)."</td></tr>
<tr><td colspan='2'><strong>Location Address:</strong> ".stripslashes($address)."</td></tr>
<tr><td colspan='2'><strong>Assigner's Telephone:</strong> $phone</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>Upon completion of the game, please fill out the attached Report <a href='http://www.njsa-assignments.com/report/report.doc' target='_blank'>http://www.njsa-assignments.com/report/report.doc</a> and mail it to the $leaname WITHIN 24 HOURS at the address below:</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>".stripslashes($league_address)."</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>Please login at following link to accept or reject Assigned Game:</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'><a href='$sitepath' target='_blank'>$sitepath</a></td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>Regards,</td></tr>
<tr><td colspan='2'>John Zangrilli</td></tr>
<tr><td colspan='2'><a href='mailto:[email protected]' target='_blank'>[email protected]</a></td></tr>
<tr><td colspan='2'> </td></tr>
</table>
</body>
</html>";

 //echo $mailcontent; 

 $to=$email;
 $subject="Assigning details for game: ".stripslashes($htname)." VS ".stripslashes($atname);;
 $from="[email protected]";

/* echo $to.'<br>';
 echo $subject.'<br>';
 echo $from.'<br>';
 echo $mailcontent.'<br>'; exit;*/

@SendHTMLMail1($to,$subject,$mailcontent,$from);

}

if($ast_ref_id1!='')
{
$sql_mainref="select fname,lname,email from referees where id=".$ast_ref_id1;
$res_mainref=mysql_query($sql_mainref);
$row_mainref=mysql_fetch_object($res_mainref);

$fname=$row_mainref->fname;
$lname=$row_mainref->lname;
$email=$row_mainref->email;



$mailcontent="<html><head></head><body>
<table width='80%' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr><td colspan='2'> </td></tr>
<tr>
<td width='47%' height='56'>Dear <b>$fname $lname</b>,</td>
<td width='117' align='center' nowrap='nowrap'></td>
</tr>

<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>You have been assigned to the following game by Assigner <strong>".$flname."</strong> and and You have been selected as <strong>Assistant Referee 1</strong>:</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'><strong>League:</strong> ".stripslashes($leaname)."</td></tr>
<tr><td colspan='2'><strong>Division:</strong> ".stripslashes($dname)."</td></tr>
<tr><td colspan='2'><strong>Assistant Referee Fee:</strong> $$ast_ref1_fee</td></tr>
<tr><td colspan='2'><strong>Home Team Name:</strong> ".stripslashes($htname)."</td></tr>
<tr><td colspan='2'><strong>Away Team Name:</strong> ".stripslashes($atname)."</td></tr>
<tr><td colspan='2'><strong>Home Team Manager:</strong> ".stripslashes($htmanager)."</td></tr>
<tr><td colspan='2'><strong>Telephone:</strong> $telephone</td></tr>
<tr><td colspan='2'><strong>Game Date:</strong> $gdate</td></tr>
<tr><td colspan='2'><strong>Game Time:</strong> $gtime</td></tr>
<tr><td colspan='2'><strong>Location:</strong> ".stripslashes($locname)."</td></tr>
<tr><td colspan='2'><strong>Location Address:</strong> ".stripslashes($address)."</td></tr>
<tr><td colspan='2'><strong>Assigner's Telephone:</strong> $phone</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>Upon completion of the game, please fill out the attached Report <a href='http://www.njsa-assignments.com/report/report.doc' target='_blank'>http://www.njsa-assignments.com/report/report.doc</a> and mail it to the $leaname WITHIN 24 HOURS at the address below:</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>".stripslashes($league_address)."</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>Please login at following link to accept or reject Assigned Game:</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'><a href='$sitepath' target='_blank'>$sitepath</a></td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>Regards,</td></tr>
<tr><td colspan='2'>John Zangrilli</td></tr>
<tr><td colspan='2'><a href='mailto:[email protected]' target='_blank'>[email protected]</a></td></tr>
<tr><td colspan='2'> </td></tr>
</table>
</body>
</html>";

 $to=$email;
 $subject="Assigning details for game: ".stripslashes($htname)." VS ".stripslashes($atname);
 $from="[email protected]";

 //echo $mailcontent;

@SendHTMLMail1($to,$subject,$mailcontent,$from);

}

if($ast_ref_id2!='')
{
$sql_mainref="select fname,lname,email from referees where id=".$ast_ref_id2;
$res_mainref=mysql_query($sql_mainref);
$row_mainref=mysql_fetch_object($res_mainref);

$fname=$row_mainref->fname;
$lname=$row_mainref->lname;
$email=$row_mainref->email;

$mailcontent="<html><head></head><body>
<table width='80%' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr><td colspan='2'> </td></tr>
<tr>
<td width='47%' height='56'>Dear <b>$fname $lname</b>,</td>
<td width='117' align='center' nowrap='nowrap'></td>
</tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>You have been assigned to the following game by Assigner <strong>".$flname."</strong> and and You have been selected as <strong>Assistant Referee 2</strong>:</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'><strong>League:</strong> ".stripslashes($leaname)."</td></tr>
<tr><td colspan='2'><strong>Division:</strong> ".stripslashes($dname)."</td></tr>
<tr><td colspan='2'><strong>Assistant Referee Fee:</strong> $$ast_ref2_fee</td></tr>
<tr><td colspan='2'><strong>Home Team Name:</strong> ".stripslashes($htname)."</td></tr>
<tr><td colspan='2'><strong>Away Team Name:</strong> ".stripslashes($atname)."</td></tr>
<tr><td colspan='2'><strong>Home Team Manager:</strong> ".stripslashes($htmanager)."</td></tr>
<tr><td colspan='2'><strong>Telephone:</strong> $telephone</td></tr>
<tr><td colspan='2'><strong>Game Date:</strong> $gdate</td></tr>
<tr><td colspan='2'><strong>Game Time:</strong> $gtime</td></tr>
<tr><td colspan='2'><strong>Location:</strong> ".stripslashes($locname)."</td></tr>
<tr><td colspan='2'><strong>Location Address:</strong> ".stripslashes($address)."</td></tr>
<tr><td colspan='2'><strong>Assigner's Telephone:</strong> $phone</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>Upon completion of the game, please fill out the attached Report <a href='http://www.njsa-assignments.com/report/report.doc' target='_blank'>http://www.njsa-assignments.com/report/report.doc</a> and mail it to the $leaname WITHIN 24 HOURS at the address below:</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>".stripslashes($league_address)."</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>Please login at following link to accept or reject Assigned Game:</td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'><a href='$sitepath' target='_blank'>$sitepath</a></td></tr>
<tr><td colspan='2'> </td></tr>
<tr><td colspan='2'>Regards,</td></tr>
<tr><td colspan='2'>John Zangrilli</td></tr>
<tr><td colspan='2'><a href='mailto:[email protected]' target='_blank'>[email protected]</a></td></tr>
<tr><td colspan='2'> </td></tr>
</table>
</body>
</html>";

//echo $mailcontent; exit;

 $to=$email;
 $subject="Assigning details for game: ".stripslashes($htname)." VS ".stripslashes($atname);;
 $from="[email protected]";

@SendHTMLMail1($to,$subject,$mailcontent,$from);

}

//exit;
}

}
//die("done");
header("location:message.php?mid=26");
exit;

}

if($_REQUEST["sub1"]==1)
{
$sql_gamec="select id,gid from games where 1=1";

if($_REQUEST['txtfromdate']!='')
{
	$txtfromdate=$_REQUEST['txtfromdate'];
	$txtfromdate_arr=explode("-",$txtfromdate);
	$txtfromdate=$txtfromdate_arr[2].'-'.$txtfromdate_arr[0].'-'.$txtfromdate_arr[1];

	$txttodate=$_REQUEST['txttodate'];
	$txttodate_arr=explode("-",$txttodate);
	$txttodate=$txttodate_arr[2].'-'.$txttodate_arr[0].'-'.$txttodate_arr[1];

	$sql_gamec.=" and gdate >='".$txtfromdate."' and gdate<='".$txttodate."'";

}

if($_REQUEST['drpdivisions']!='')
{
	$sql_gamec.=" and div_id=".$_REQUEST['drpdivisions'];
}

	if($_REQUEST['drpleague']!='')
   {
		$sql_gamec.=" and league_id=".$_REQUEST['drpleague'];
		$league=$_REQUEST['drpleague'];
   }

$sql_gamec.=" order by id desc";

//echo $sql_gamec; exit;

$res_gamec=mysql_query($sql_gamec);
$totgames=mysql_num_rows($res_gamec);

}
if($_REQUEST["sub2"]==1)
{
}
if($_GET["gid"])
{
$game_id=$_GET['gid'];	

$selsql= "SELECT lea.league_name,lea.address as league_address,d.mainref_fee,d.astref_fee,g.htmanager,g.telephone,g.id, g.gid,g.gdate,dayname(g.gdate) as gday,g.gtime, d.dname, ht.tname AS htname, at.tname AS atname, l.lname,l.address
FROM games g
INNER JOIN divisions d ON g.div_id = d.id
INNER JOIN league lea ON g.league_id = lea.id
INNER JOIN teams ht ON g.home_team_id = ht.id
INNER JOIN teams at ON g.away_team_id = at.id
INNER JOIN locations l ON g.location_id = l.id
where gid=".$_GET["gid"]  ;
$selres = mysql_query($selsql);
echo mysql_error();
$selobj = mysql_fetch_object($selres);

$mainref_fee = stripslashes($selobj->mainref_fee);
$astref_fee = stripslashes($selobj->astref_fee);
$league_name = stripslashes($selobj->league_name);
$league_address = stripslashes($selobj->league_address);
$dname = stripslashes($selobj->dname);
$htname = stripslashes($selobj->htname);
$atname = stripslashes($selobj->atname);

$htmanager = stripslashes($selobj->htmanager);
$telephone = stripslashes($selobj->telephone);

$gdate = stripslashes($selobj->gdate);
$gdate2 = stripslashes($selobj->gdate);
$kgdate=explode('-',$gdate);
$gdate=$kgdate[1].'-'.$kgdate[2].'-'.$kgdate[0];

$gtime = stripslashes($selobj->gtime);

$htime=explode(':',$gtime);

$ampm=explode(' ',$htime[1]);

$lname = stripslashes($selobj->lname);
$address = stripslashes($selobj->address);

$gday=stripslashes($selobj->gday);

/*$sql_ref_fee="select * from referee_fees";
$res_ref_fee=mysql_query($sql_ref_fee);
$row_ref_fee=mysql_fetch_object($res_ref_fee);

$mainref_fee=$row_ref_fee->mainref_fee;
$astref_fee=$row_ref_fee->astref_fee;
	*/
//echo $gday;
 //echo $sql_mainref="select id,fname,lname from referees where '".$gdate2."' NOT BETWEEN fromdate and todate";  


}

if($_GET['league_id']!='')
$league=$_GET['league_id'];

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><title><?=Site_Title; ?></title>
<script language="javascript">

function printPopup()
{
var sql=document.getElementById('sql').value;
var a = window.open("print.php?sql="+sql,"Print","width=800px,height=500px,scrollbars=1");
}

function kyb_check()
{

var mx=document.getElementById('max').value;

//alert(mx);

for(i=1;i<=mx;i++)
{
		if(document.getElementById("astref1_"+i)!=null && document.getElementById("mainref"+i)!=null)
		{
			if(document.getElementById("mainref"+i).value!='' && document.getElementById("astref1_"+i).value!='')
			{
				if(document.getElementById("mainref"+i).value==document.getElementById("astref1_"+i).value)
				{
					alert("Main Referee and Assistant Referee can not be Same for game. Please check again");
					document.getElementById("mainref"+i).focus();
					return false;
				}
			}
		}

		if(document.getElementById("astref2_"+i)!=null && document.getElementById("mainref"+i)!=null)
		{
			if(document.getElementById("mainref"+i).value!='' && document.getElementById("astref2_"+i).value!='')
			{
				if(document.getElementById("mainref"+i).value==document.getElementById("astref2_"+i).value)
				{
					alert("Main Referee and Assistant Referee can not be Same for game. Please check again");
					document.getElementById("mainref"+i).focus();
					return false;
				}
			}
		}

		if(document.getElementById("astref1_"+i)!=null && document.getElementById("astref2_"+i)!=null)
		{
			if(document.getElementById("astref1_"+i).value!='' && document.getElementById("astref2_"+i).value!='')
			{
				if(document.getElementById("astref1_"+i).value==document.getElementById("astref2_"+i).value)
				{
					alert("Assistant Referee 1 and Assistant Referee 2 can not be Same for game. Please check again");
					document.getElementById("astref1_"+i).focus();
					return false;
				}
			}
		}
}


}
function clearall()
{
document.getElementById('txtfromdate').value='';
document.getElementById('txttodate').value='';
document.getElementById('drpdivisions').value='';
}
function IsNumericMain(strString)
   //  check for valid numeric strings	
   {
    var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
	 alert("Please Enter Digits");
	 document.getElementById('main_ref_fee').value='';
	 document.getElementById('main_ref_fee').focus();
         blnResult = false;
         }
      }
   return blnResult;
   }
function IsNumericAstRef1(strString)
{
    var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
	 alert("Please Enter Digits");
	 document.getElementById('ast_ref1_fee').value='';
	 document.getElementById('ast_ref1_fee').focus();
         blnResult = false;
         }
      }
   return blnResult;
}
function IsNumericAstRef2(strString)
{
    var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
	 alert("Please Enter Digits");
	 document.getElementById('ast_ref2_fee').value='';
	 document.getElementById('ast_ref2_fee').focus();
         blnResult = false;
         }
      }
   return blnResult;
}

function select_game(val,sub1,txtfrom,txtto,drp_division)
{
window.location.href='assign_referee_to_game.php?gid=' + val + '&sub1=' + sub1 + '&txtfromdate=' + txtfrom + '&txttodate=' + txtto + '&drpdivisions=' + drp_division;

}
function show_divisions(val)
{
window.location.href='assign_referee_to_game.php?league_id=' + val;

}
function show_getgames()
{
//alert("Aa");
if(document.getElementById('txtfromdate').value!='' && document.getElementById('txttodate').value=='')
{
	alert('Please Select To Date');
	document.getElementById('txttodate').focus();
	return false;
}
if(document.getElementById('txttodate').value!='' && document.getElementById('txtfromdate').value=='')
{
	alert('Please Select From Date');
	document.getElementById('txtfromdate').focus();
	return false;
}
if(document.getElementById('txttodate').value < document.getElementById('txtfromdate').value)
{
	alert('To Date can not be less then From Date');
	document.getElementById('txttodate').focus();
	return false;
}

document.getElementById('sub1').value=1;
document.frmgetgames.submit();
}

</script>
<script src="calendar.js"></script>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<link rel="stylesheet" href="main.css" type="text/css">
<style type="text/css">
p.uppercase {text-transform:uppercase;}
</style>
</HEAD>
<BODY  leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 class="th-a">
  <TR><TD height=60   colspan="2" bgColor=#FFFFFF><? include("top.php") ?></td>
  </TR>
  <tr>
	<td width="20%" valign="top" bgcolor="#1c6995"><? include("left.php"); ?></td>
	<td width="80%" valign="top" height="480" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="2">
          <tr>
            <td>  </td>
          </tr>
          <tr>
            <td valign="top"> </td>
          </tr>
          <tr>
            <td><form name="frmgetgames" id="frmgetgames" method="post">
			<table width="581" border="0" align="center" cellpadding="4" cellspacing="0">
<tr>
                              <td width="100%" colspan="2" align="left" class="solidinput">
                                <div align="left">From Date: 
                                  <input type="text" name="txtfromdate" readonly="true" id="txtfromdate" size="15" value="<?=stripslashes($_REQUEST['txtfromdate']);?>">
                                   <a href="#" onClick="getCalendar(document.getElementById('txtfromdate'));"> Select Date</a>   To Date: 
                                  <input type="text" name="txttodate" readonly="true" id="txttodate" size="15" value="<?=stripslashes($_REQUEST['txttodate']);?>">
                                   <a href="#" onClick="getCalendar(document.getElementById('txttodate'));"> Select Date</a>      <br>
                                  <br>
						      <select name="drpleague" id="drpleague" style="width:150px" onChange="show_divisions(this.value)">
						        <option value="">--Select--</option>
						        <? 
						  	  $sql_league="select * from league";
							  $res_league=mysql_query($sql_league);
							  while($row_league=mysql_fetch_object($res_league))
							  {
						  ?>
						        <option value="<?=$row_league->id?>" <? if($row_league->id==$league) echo "selected='selected'"; ?>>
					            <?=stripslashes($row_league->league_name)?>
					            </option>
						        <? } ?>
					          </select>
    
<? if($league!='') { ?>
						      <select id="drpdivisions" name="drpdivisions">
						        <option value="">--Select Division--</option>
						        <? 
								$sql_division="select * from divisions where league_id=".$league." order by dname";
								$res_division=mysql_query($sql_division);
								while($row_division=mysql_fetch_object($res_division))
								{
							?>
						        <option value="<?=$row_division->id?>" <? if($_REQUEST['drpdivisions']==$row_division->id) echo "selected='selected'"; ?>>
					            <?=stripslashes($row_division->dname);?>
					            </option>
						        <? } ?>
					          </select>
						      <? } ?>
						      <br>
						      <br>
						      <input type="button" value="Get Games" onClick="show_getgames();">
						      <input type="hidden" id="sub1" name="sub1" value="0">
    
<input type="button" value="Clear" onClick="clearall();">                              
				            </div></td>
                  </tr>
		  </table>
			<div align="center"></div>
			<div align="center"></div>
            </form></td>
          </tr>
          <tr>
            <td> </td>
          </tr>
        </table>
        
          
          <div align="right">
            <? if(isset($_REQUEST['sub1']) && $_REQUEST['sub1']=='1') { ?>
            
                          <?
	  	$sql_games="select * from games where gid not in (select gid from assigned_games)";

		if($txtfromdate!='')
		{

			$sql_games.=" and gdate >='".$txtfromdate."' and gdate<='".$txttodate."'";
		}

		if($_REQUEST['drpdivisions']!='')
		{
			$sql_games.=" and div_id=".$_REQUEST['drpdivisions'];
		}

		 if($_REQUEST['drpleague']!='')
		   {
				$sql_games.=" and league_id=".$_REQUEST['drpleague'];
				$league=$_REQUEST['drpleague'];
		   }

		//print('aa'.$sql_games);
	  	$rs_games=mysql_query($sql_games) or die('aa'.mysql_error());
		$max=0;
		if(mysql_num_rows($rs_games)>0)
		{
?>
               <img src="images/print_icon.jpg" alt="Print" width="35" height="39" onClick="printPopup()" style="cursor:pointer;">        </div>
          <form name="form1" method="post" action="">
	    <table width="100%" cellpadding="2" cellspacing="0" class="t-a">
              
              <tr>
                <td height="42" colspan="9" class="H4">Assign Referee to A Game                </td>
              </tr>
              <tr>
                <td width="6%" height="27" class="th-a">League </td>
                <td width="6%" class="th-a">Division</td>
                <td width="10%" class="th-a">Home Team</td>
                <td width="9%" class="th-a">Away Team</td>
                <td width="8%" class="th-a">Date of Game</td>
                <td width="6%" class="th-a"> Time</td>
                <td width="11%" class="th-a">Location Name</td>
                <td width="13%" class="th-a">Location Address</td>
                <td width="31%" class="th-a">Referees</td>
              </tr>
		<?
		while($row_games=mysql_fetch_object($rs_games))
		{
			$league=getLeague($row_games->league_id);

			$leaguecode=$league->league_code;
			$leaguename=$league->league_name;
			$leagueaddress=$league->address;

			$division=getDivision($row_games->div_id);

			$divisioncode=$division->dcode;
			$divisionname=$division->dname;
			$MainRefereeFee=$division->mainref_fee;
			$AstRefereeFee=$division->astref_fee;

			$HomeTeam=getTeam($row_games->home_team_id);

			$HomeTeamName=$HomeTeam->tname;
			$HomeTeamManager=$HomeTeam->htmanager;
			$HomeTeamPhone=$HomeTeam->phone;		

			$AwayTeam=getTeam($row_games->away_team_id);

			$AwayTeamName=$AwayTeam->tname;

			$txtgdate=$row_games->gdate;
			$txtgdate_arr=explode("-",$txtgdate);
			$txtgdate=$txtgdate_arr[1].'-'.$txtgdate_arr[2].'-'.$txtgdate_arr[0];

			$txtgtime=$row_games->gtime;
			$txtgtime_arr=explode("-",$txtgtime);
			$txtgtime=$txtgtime_arr[1].''.$txtgtime_arr[2].''.$txtgtime_arr[0];

			$row_location=getLocation($row_games->location_id);

			$loc_name=$row_location->lname;
			$loc_address=$row_location->address;

			$max++;

			print('<tr>
					<td>'.$leaguecode.'<input type="hidden" id="leaname'.$max.'" name="leaname'.$max.'" value="'.$leaguename.'"><input type="hidden" id="league_address'.$max.'" name="league_address'.$max.'" value="'.$leagueaddress.'"></td>
					<td>'.$divisioncode.'<input type="hidden" id="dname'.$max.'" name="dname'.$max.'" value="'.$divisionname.'"></td>
					<td>'.$HomeTeamName.'<input type="hidden" id="htname'.$max.'" name="htname'.$max.'" value="'.$HomeTeamName.'"></td>
					<td>'.$AwayTeamName.'<input type="hidden" id="atname'.$max.'" name="atname'.$max.'" value="'.$AwayTeamName.'">
<input type="hidden" id="htmanager'.$max.'" name="htmanager'.$max.'" value="'.$HomeTeamManager.'"><input type="hidden" id="telephone'.$max.'" name="telephone'.$max.'" value="'.$HomeTeamPhone.'"></td>
					<td>'.$txtgdate.'<input type="hidden" id="gdate'.$max.'" name="gdate'.$max.'" value="'.$txtgdate.'"></td>
					<td>'.$txtgtime.'<input type="hidden" id="gtime'.$max.'" name="gtime'.$max.'" value="'.$txtgtime.'"></td>
					<td>'.$loc_name.'<input type="hidden" id="lname'.$max.'" name="lname'.$max.'" value="'.$loc_name.'"></td>
					<td>'.$loc_address.'<input type="hidden" id="address'.$max.'" name="address'.$max.'" value="'.$loc_address.'"></td>
					<td> 
						Referee: '.getReferee($row_games->gdate,mainref.$max).'<input type="hidden" name="mainref_fee'.$max.'" value="'.$MainRefereeFee.'"><br><br>
						Assistant Referee 1: '.getReferee($row_games->gdate,astref1.'_'.$max).'<input type="hidden" name="astref_fee'.$max.'" value="'.$AstRefereeFee.'"><br><br>
						Assistant Referee 2: '.getReferee($row_games->gdate,astref2.'_'.$max).'<br>
						<input name="gid'.$max.'" type="hidden" value="'.$max.'">
					</td>
				  </tr>
				');


		}
	  ?>
          <tr>
          <td colspan="9">
            </td>
          </tr>
          <tr>
          <td colspan="9">
            <div align="center">
              <input type="hidden" name="max" id="max" value="<?=$max?>">
              <input name="Submit" type="submit" class="buttonclass" value="Submit" onClick="return kyb_check();" />
              <input type="hidden" name="sql" id="sql" value="<?=$sql_games?>">
              <input type="hidden" name="sub2" value="1">
            </div></td>
          </tr>
            </table>
          </form>
               <?
	  }//end of num rows if
	  
	  else
	  {
	  		print('<div align="left"><font color="red"><strong>No Games will be played between these Dates!</strong></font></div>');
	  }
	  
	  ?>
     
          <? } ?>
    </td>
  </tr>
</TABLE>
</BODY></HTML>

 

Link to comment
https://forums.phpfreaks.com/topic/196394-order-sort-by/#findComment-1031306
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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