Jump to content

Post filtered information from database


miniu

Recommended Posts

Hi again. I have two files. assign_referee.php and referee_usage_report.php

 

In the first file I am choosing  a referee in the second I can see when he did his last game. But I want to do something more. When I select the referee as a drop down menu I want that below will be automatically posted a line with the last games that he did in the past 3 weeks in a form like that (league, htname, atname, date (Referee or Assistant Referee).

 

the line with the code where I choose the referee is look like that:

 

							<? if($mainref_fee!='') { ?>
						<tr>
                              <td width="37%" align="right"><font color="red"></font> Referee:</td>
                              <td width="63%">
						  <font color="<?=$col?>"><select id="mainref" name="mainref" style="width:180px">
						  	<option value="">--Select--</option>
						  <?
						  		$sql_mainref = "SELECT id, lname, fname FROM `referees` WHERE '".$gdate2."' NOT BETWEEN fromdate AND todate ORDER BY lname";
								$res_mainref=mysql_query($sql_mainref);
								while($row_mainref=mysql_fetch_object($res_mainref))
								{ ?>
								<option value="<?=$row_mainref->id?>"><?=$row_mainref->lname.' '.$row_mainref->fname?></option>
							<?	}
						  ?>
						  </select>
                              </font></td>
                            </tr>
						<? } else { ?>
					<input type="hidden" name="old_main_ref_id" id="old_main_ref_id" value="<?=$main_ref_id?>">
					<input type="hidden" name="mainref_fee" value="<?=$mainref_fee?>">
					<? } ?>
					<? if($astref_fee!='') { ?>
						<tr>
                              <td width="37%" align="right"><font color="red"></font> Assistant Referee 1:</td>
                              <td width="63%"><font color="<?=$col?>"><select id="astref1" name="astref1" style="width:180px">
						  	<option value="">--Select--</option>
						  <?
						  		$sql_astref1="select id,fname,lname from referees where '".$gdate2."' NOT BETWEEN fromdate and todate ORDER BY lname"; 
								$res_astref1=mysql_query($sql_astref1);
								while($row_astref1=mysql_fetch_object($res_astref1))
								{ ?>
								<option value="<?=$row_astref1->id?>"><?=$row_astref1->lname.' '.$row_astref1->fname?></option>
							<?	}
						  ?>
						  </select>
                              </font></td>
                            </tr>
						<? } else { ?>
					<input type="hidden" name="old_ast_ref_id1" id="old_ast_ref_id1" value="<?=$ast_ref_id1?>">
					<input type="hidden" name="astref_fee" value="<?=$astref_fee?>">
					<? } ?>
					<? if($astref_fee!='') { ?>
						<tr>
                              <td width="37%" align="right"><font color="red"></font> Assistant Referee 2:</td>
                              <td width="63%"><font color="<?=$col?>"><select id="astref2" name="astref2" style="width:180px">
						  	<option value="">--Select--</option>
						  <?
						  		$sql_astref2="select id,fname,lname from referees where '".$gdate2."' NOT BETWEEN fromdate and todate ORDER BY lname"; 
								$res_astref2=mysql_query($sql_astref2);
								while($row_astref2=mysql_fetch_object($res_astref2))
								{ ?>
								<option value="<?=$row_astref2->id?>"><?=$row_astref2->lname.' '.$row_astref2->fname?></option>
							<?	}
						  ?>
						  </select>
                              </font></td>
                            </tr>

 

And this is the part with the Usage report:

 

<?php include("connect.php");
include("admin.session.php");
$LeftLinkSection = 1;
$pagetitle="Referees To Game";

if(isset($_GET['did']))
{
$sql="delete from assigned_games where id=".$_GET['did'];
$res=mysql_query($sql);
echo mysql_error();
header('location:message.php?mid=27');
}

if($_POST['sub11']==1)
{
$ref_id=$_POST['drpreferee']; 
}

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


?>
<HTML>
<HEAD><title><?=Site_Title; ?></title>
<SCRIPT language="javascript" src="body.js"></SCRIPT>
<script>
function show_divisions(val)
{
window.location.href='manage_referees_to_game.php?league_id=' + val;

}
function show_getgames()
{
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;
}
if(document.getElementById('refsel').value!='')
{
	if(document.getElementById('drpreferee').value=='')
	{
		alert('Please select referee Name');
		document.getElementById('drpreferee').focus();
		return false;
	}
}



document.getElementById('sub11').value=1;
document.frmgetgames.submit();
}
function clearall()
{
document.getElementById('txtfromdate').value='';
document.getElementById('txttodate').value='';
document.getElementById('refsel').value='';
document.getElementById('drpdivisions').value='';

}
function openWin(pageToLoad, winName, width, height, center,scrollbar){

  if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
	        xposition = (screen.width - width) / 2;
	        yposition = (screen.height - height - 100) / 2;
args = "width=" + width + "," + "height=" + height + "," + "location=0," + "menubar=0," + "resizable=no," + "scrollbars=" + scrollbar + "," + "status=0," + "titlebar=0," + "toolbar=0," + "hotkeys=0," + "screenx=" + xposition + "," + "screeny=" + yposition + "," + "left=" + xposition + "," + "top=" + yposition;
newWindow = window.open(pageToLoad,winName,args);	
window.focus;
}
}
</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">
<!--
.style3 {color: #FFFFFF}
-->
</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 valign="top"  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" bgcolor="#FFFFFF" height="480">
		<TABLE width="97%"  border=0 cellPadding=0 cellSpacing=0 align="center">
			<TR><TD width="100%"  class="H1"> </TD></TR>
			<TR><TD align="center" width="100%" class="a-l"><?php echo $Message2 ; ?></TD></TR>
	    <TR>
		<? if($msg!="") { ?>
		<TR><TD align="center" width="100%" class="a-l"><font color="red"><b>User Deleted Successfully</b></font></TD></TR>
	    <TR>
		<? } ?>
	      <TD width="100%" class="H1">Referee Usage Report</TD>
	    </TR>
			<TR><TD background="images/vdots.gif"><IMG height=1 src="images/spacer.gif" width=1 border=0></TD></TR>
		  <tr>
				<TD>

				<FORM  name="order" action="#" method="post">
    				  <TABLE cellSpacing=0 cellPadding=1 border=0 >
							<tr><td colspan="25" height="20"><b>View By Main Referee Name</b></td></tr>
							<?=$prs_pageing->order();?>
					</TABLE>
				  </form>
				  <br><form name="frmgetgames" id="frmgetgames" method="post">
				  <table cellpadding="0" cellspacing="0" border="0">
			<tr>
                              <td width="100%" colspan="2" align="center">
                            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>      <input type="button" value="Get Games" onClick="show_getgames();"><input type="hidden" id="sub11" name="sub11" value="0">  <input type="button" value="Clear" onClick="clearall();">
                              </td>
                            </tr>
						<tr><td colspan="2"> </td></tr>
			<tr>
                              <td width="100%" colspan="2" align="left"><select id="refsel" name="refsel">
						  <option value="" <? if($_POST['refsel']==' ') echo "selected='selected'"; ?>>--Select--</option>
	<option value="0" <? if($_POST['refsel']!='') { if($_POST['refsel']==0) echo "selected='selected'"; } ?>>How many games did the referee as a Main referee</option>
	<option value="1" <? if($_POST['refsel']==1) echo "selected='selected'"; ?>>How many games did the referee as a Assistant Referee 1</option>
<option value="2" <? if($_POST['refsel']==2) echo "selected='selected'"; ?>>How many games did the referee as a Assistant Referee 2</option>
<option value="4" <? if($_POST['refsel']==4) echo "selected='selected'"; ?>>And Last time that he did a game</option>
						  </select>  <select name="drpreferee" id="drpreferee" style="width:150px">
						  <option value="">--Select--</option>
						  <? 
						  	  $sql_referee="select * from referees ORDER BY lname";
							  $res_referee=mysql_query($sql_referee);
							  while($row_referee=mysql_fetch_object($res_referee))
							  {
						  ?>
						  <option value="<?=$row_referee->id?>" <? if($row_referee->id==$ref_id) echo "selected='selected'"; ?>><? echo stripslashes($row_referee->lname).' '.stripslashes($row_referee->fname); ?></option>
						  <? } ?>
						  </select>
						  </td></tr>

			</table></form><br>

<?	
  	if($_GET["order"])
{
	$order=$_GET["order"];
  $strQueryPerPage="select lea.league_name,ht.tname as htname,at.tname as atname,d.dname,g.gdate,ag.id,ag.gid,ag.main_ref_id,ag.ast_ref_id1,ag.ast_ref_id2,ag.main_ref_accept,ag.ast_ref1_accept,ag.ast_ref2_accept,r1.fname as r1fname,r1.lname as r1lname,r2.fname as r2fname,r2.lname as r2lname,r3.fname as r3fname,r3.lname as r3lname from assigned_games ag left outer join referees r1 on ag.main_ref_id=r1.id left outer join referees r2 on ag.ast_ref_id1=r2.id left outer join referees r3 on ag.ast_ref_id2=r3.id left outer join games g on ag.gid=g.gid left outer join divisions d on g.div_id=d.id left outer join league lea on g.league_id=lea.id left outer join teams ht on g.home_team_id=ht.id left outer join teams at on g.away_team_id=at.id where r1.fname like '$order%'";
}
else
  	$strQueryPerPage="select lea.league_name,ht.tname as htname,at.tname as atname,d.dname,g.gdate,ag.main_ref_id,ag.ast_ref_id1,ag.ast_ref_id2,ag.id,ag.gid,ag.main_ref_accept,ag.ast_ref1_accept,ag.ast_ref2_accept,r1.fname as r1fname,r1.lname as r1lname,r2.fname as r2fname,r2.lname as r2lname,r3.fname as r3fname,r3.lname as r3lname from assigned_games ag left outer join referees r1 on ag.main_ref_id=r1.id left outer join referees r2 on ag.ast_ref_id1=r2.id left outer join referees r3 on ag.ast_ref_id2=r3.id left outer join games g on ag.gid=g.gid left outer join divisions d on g.div_id=d.id left outer join league lea on g.league_id=lea.id left outer join teams ht on g.home_team_id=ht.id left outer join teams at on g.away_team_id=at.id where 1=1";

//echo $strQueryPerPage;

if($_POST['sub11']==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];

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

	if($_POST['refsel']!='')
	{
		if($_POST['refsel']==0)
		{
			$strQueryPerPage.=" and ag.main_ref_id=".$_POST['drpreferee'];

		}
		if($_POST['refsel']==1)
		{
			$strQueryPerPage.=" and ag.ast_ref_id1=".$_POST['drpreferee'];

		}
		if($_POST['refsel']==2)
		{
			$strQueryPerPage.=" and ag.ast_ref_id2=".$_POST['drpreferee'];

		}
		if($_POST['refsel']==3)
		{
			$strQueryPerPage.=" and (ag.main_ref_accept='A' or ag.ast_ref1_accept='A' or ag.ast_ref2_accept='A') and (ag.main_ref_id=".$_POST['drpreferee']." or ag.ast_ref_id1=".$_POST['drpreferee']." or ag.ast_ref_id2=".$_POST['drpreferee'];

		}

   }

}

if(isset($_GET['sort']))
	$strQueryPerPage.=" order by ".$_GET['sort']." ".$_GET['ordby'];
else
	$strQueryPerPage.=" order by ag.id desc";

//echo $strQueryPerPage;

$strResultPerPage=mysql_query($strQueryPerPage);
$strTotalPerPage=mysql_affected_rows(); 	
?>

          <FORM name="form2" action="#" method="post">          
          <TABLE width="100%" height="89" border=1 cellSpacing=0 class=t-a>
            <!--DWLayoutTable-->
            <TBODY>
              <TR class="th-a"> 
		     <TD colspan="9">					 
				 <?
					$result=$prs_pageing->number_pageing($strQueryPerPage,15,7);
				?>			  </TD>                 
        	 </TR>		

              <TR class=th-a>
		  	<TD width="12%" align="left"><a href="manage_referees_to_game.php?sort=lea.league_name&<? if($_GET['ordby']=='asc' || $_GET['ordby']=='' ) {?>ordby=desc<? } else {?>ordby=asc<? } ?>" class="link2">League Name</a></TD> 
                <TD width="12%" align="left"><a href="manage_referees_to_game.php?sort=d.dname&<? if($_GET['ordby']=='asc' || $_GET['ordby']=='' ) {?>ordby=desc<? } else {?>ordby=asc<? } ?>" class="link2">Division</a></TD> 
			<TD width="12%" align="left"><a href="manage_referees_to_game.php?sort=at.tname&<? if($_GET['ordby']=='asc' || $_GET['ordby']=='' ) {?>ordby=desc<? } else {?>ordby=asc<? } ?>" class="link2">Home Team</a></TD> 
			<TD width="12%" align="left"><a href="manage_referees_to_game.php?sort=ht.tname&<? if($_GET['ordby']=='asc' || $_GET['ordby']=='' ) {?>ordby=desc<? } else {?>ordby=asc<? } ?>" class="link2">Away Team</a></TD> 
			<TD width="12%" align="left"><a href="manage_referees_to_game.php?sort=g.gdate&<? if($_GET['ordby']=='asc' || $_GET['ordby']=='' ) {?>ordby=desc<? } else {?>ordby=asc<? } ?>" class="link2">Game Date</a></TD> 
			<TD width="12%" align="left"><a href="manage_referees_to_game.php?sort=r1.fname&<? if($_GET['ordby']=='asc' || $_GET['ordby']=='' ) {?>ordby=desc<? } else {?>ordby=asc<? } ?>" class="link2">Main Referee</a></TD> 
			<TD width="12%" align="left"><a href="manage_referees_to_game.php?sort=r2.fname&<? if($_GET['ordby']=='asc' || $_GET['ordby']=='' ) {?>ordby=desc<? } else {?>ordby=asc<? } ?>" class="link2">Assistant Referee 1</a></TD> 
			<TD width="12%" align="left"><a href="manage_referees_to_game.php?sort=r3.fname&<? if($_GET['ordby']=='asc' || $_GET['ordby']=='' ) {?>ordby=desc<? } else {?>ordby=asc<? } ?>" class="link2">Assistant Referee 2</a></TD> 
		  	<TD width="16%" align="center"><span class="style3">Option</span></TD>
              </TR>
          <?php
	  $tr="#f4f4f4";
	  $clr=1;
		while($row = mysql_fetch_object($result))
		{

			if($tr=="#FFFFFF")
			{
				$tr="#efefef";
				$col="#000000";
			}
			else
			{
				$tr="#FFFFFF";
				$col="#000000";
			}
			$tmpid = $row->id ;

			$tmpid = "";

			$agid=$row->id;

        ?>
              <tr bgcolor="<? echo $tr; ?>">
		 <TD  align="left"><font color="<?=$col?>"><? echo stripslashes($row->league_name); ?></font></TD>
      	    <TD  align="left"><font color="<?=$col?>"><? echo stripslashes($row->dname); ?></font></TD>
		<TD  align="left"><font color="<?=$col?>"><? echo stripslashes($row->htname); ?></font></TD>
		<TD  align="left"><font color="<?=$col?>"><? echo stripslashes($row->atname); ?></font></TD>
		<TD  align="left"><font color="<?=$col?>"><? echo stripslashes($row->gdate); ?></font></TD>
<TD  align="left"><font color="<?=$col?>"> <? echo stripslashes($row->r1fname).' '.stripslashes($row->r1lname); ?><br><? if($row->main_ref_accept=='P' && $row->main_ref_id!=0) echo "<font color='#FF9900'><b>Pending</b></font>"; ?><? if($row->main_ref_accept=='A') echo "<font color='#006633'><b>Accepted</b></font>"; ?><? if($row->main_ref_accept=='R') echo "<font color='#FF0000'><b>Rejected</b></font><a href='#' onclick=\"openWin('view_reason.php?mainref_id=$agid','test','550','500','true','yes');\">(View Reason)</a>"; ?></font></TD>
<TD  align="left"><font color="<?=$col?>"> <? echo stripslashes($row->r2fname).' '.stripslashes($row->r2lname); ?></font><br><? if($row->r2fname!='') { if($row->ast_ref1_accept=='P' && $row->ast_ref_id1!=0) echo "<font color='#FF9900'><b>Pending</b></font>"; ?><? if($row->ast_ref1_accept=='A') echo "<font color='#006633'><b>Accepted</b></font>"; ?><? if($row->ast_ref1_accept=='R') echo "<font color='#FF0000'><b>Rejected</b></font><a href='#' onclick=\"openWin('view_reason.php?astref_id1=$agid','test','550','500','true','yes');\">(View Reason)</a>"; } ?></TD>
<TD  align="left"><font color="<?=$col?>"> <? echo stripslashes($row->r3fname).' '.stripslashes($row->r3lname); ?></font><br><? if($row->r3fname!='') { if($row->ast_ref2_accept=='P' && $row->ast_ref_id2!=0) echo "<font color='#FF9900'><b>Pending</b></font>"; ?><? if($row->ast_ref2_accept=='A') echo "<font color='#006633'><b>Accepted</b></font>"; ?><? if($row->ast_ref2_accept=='R') echo "<font color='#FF0000'><b>Rejected</b></font><a href='#' onclick=\"openWin('view_reason.php?astref_id2=$agid','test','550','500','true','yes');\">(View Reason)</a>"; } ?></TD>
		    <TD align="center"><input name="button" type="button" class="bttn-s" onClick="location.href='edit_referee_to_game.php?id=<?php echo $row->id; ?>'" value="Edit">
		      <INPUT class="bttn-s" onClick="deleteconfirm('Are you sure you want to delete this Assigned Referee to Game? \n','manage_referees_to_game.php?did=<?php echo($row->id); ?>');" type="button" value="Delete">				</TD>
              </TR>
              <?  
		  		$parentary = NULL ;
		  	}	  ?>
            <input type=hidden name="total" value="<? echo $strTotalNewRow; ?>">
            <TR align=center> 
                <TD colSpan=9>
                <?
		 	if(!$strTotalPerPage)
			{
		 ?>
                  <strong>No Referees To Game Detail Display</strong> 
                  <?
		 	}
		 ?>                </TD>
            </TR>
          </TABLE>
        

        </FORM>
				</TD>
		  </TR>
		</TABLE>
	</td>
  </tr>
</TABLE>
</BODY></HTML>

 

I suppose that I have to validate this information as (i.e. <? if($_POST['refsel']==4) ), am i right?

 

Link to comment
https://forums.phpfreaks.com/topic/192204-post-filtered-information-from-database/
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.