| Current Path : /var/www/html/mmishra/indem/SC6/ |
| Current File : /var/www/html/mmishra/indem/SC6/summaryPrint.php |
<?php
ini_set('display_errors', 1);
$username = "root";
$password = "iagtku!!";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
$selected = mysql_select_db("scienceconclave13",$dbhandle)
or die("Could not select examples");
function getUserName($countryId)
{
$sql="Select countryName from tbl_country where countryId='$countryId'";
$tm = mysql_query($sql);
if($tm)
{
if ($line = mysql_fetch_array($tm))
{
$response = $line[0];
}
}
return $response;
}
function CountRecrd($countryId='',$field='',$value='')
{
$sql="Select COUNT(forrecordId) from tbl_forrecord where countryId='$countryId' ";
if($field!='')
{
$sql.= "&& $field='$value' ";
}
$tm = mysql_query($sql);
if($tm)
{
if ($line = mysql_fetch_array($tm))
{
$response = $line[0];
}
}
return $response;
}
function CountRecrdSt($state='',$field='',$value='')
{
$sql="Select COUNT(recordId) from tbl_record where state='$state' ";
if($field!='')
{
$sql.= "&& $field='$value' ";
}
$tm = mysql_query($sql);
if($tm)
{
if ($line = mysql_fetch_array($tm))
{
$response = $line[0];
}
}
return $response;
}
$sql="Select Distinct(state) from tbl_record ";
$query=mysql_query($sql);
?>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<table width="100%" cellpadding="2" cellspacing="2" border="1" >
<tr >
<td colspan="13" align="center" >Data By State ( in Numbers ) </td>
</tr>
<tr >
<td width="13%" align="center" >State Name </td>
<td colspan="2" align="center" >Gender</td>
<td colspan="2" align="center" >Participation Status </td>
<td colspan="6" align="center">Subject</td>
<td width="9%" align="center" > </td>
</tr>
<tr >
<td align="center" > </td>
<td width="7%" align="center" >Male</td>
<td width="8%" align="center" >Female</td>
<td width="6%" align="center" >Student</td>
<td width="6%" align="center" >Teacher</td>
<td width="6%" align="center" >Physics</td>
<td width="6%" align="center" >Chemistry</td>
<td width="7%" align="center" >Mathematics</td>
<td width="6%" align="center" >Bio. Sc. </td>
<td width="7%" align="center" >Engineering</td>
<td width="9%" align="center" >Others</td>
<td width="10%" align="center" >Total</td>
</tr>
<?php if(mysql_num_rows($query)>0)
{
$grandTotal=0;
$total=0;
$grandTotal=0;
$total=0;
$grandTotalM=0;
$totalM=0;
$grandTotalF=0;
$totalF=0;
$grandTotal2=0;
$total2=0;
$grandTotal3=0;
$total3=0;
$grandTotalOBC=0;
$totalOBC=0;
$grandTotalGEN=0;
$totalGEN=0;
$grandTotal6=0;
$total6=0;
$grandTotal7=0;
$total7=0;
$grandTotal8=0;
$total8=0;
$grandTotal9=0;
$total9=0;
$grandTotal10=0;
$total10=0;
?>
<?php while($row=mysql_fetch_array($query))
{
//print_r($row);
?>
<tr>
<td align="center" ><?php echo $row['state']?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'gender','0');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'gender','1');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'participantStatus','0');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'participantStatus','1');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'areaOfInterest','Physics');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'areaOfInterest','Chemistry');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'areaOfInterest','Mathematics');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'areaOfInterest','Biological Sciences');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'areaOfInterest','Engineering');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'areaOfInterest','Others');?></td>
<td align="center" ><?php echo CountRecrdSt($state=$row['state'],$field='',$value='');?></td>
</tr>
<?php
$total=CountRecrdSt($state=$row['state'],$field='',$value='');
$grandTotal=$total+$grandTotal;
$totalM=CountRecrdSt($state=$row['state'],$field='gender',$value='0');
$grandTotalM=$totalM+$grandTotalM;
$totalF=CountRecrdSt($state=$row['state'],$field='gender',$value='1');
$grandTotalF=$totalF+$grandTotalF;
$total2=CountRecrdSt($state=$row['state'],$field='participantStatus',$value='0');
$grandTotal2=$total2+$grandTotal2;
$total3=CountRecrdSt($state=$row['state'],$field='participantStatus',$value='1');
$grandTotal3=$total3+$grandTotal3;
$totalOBC=CountRecrdSt($state=$row['state'],$field='areaOfInterest',$value='Physics');
$grandTotalOBC=$totalOBC+$grandTotalOBC;
$totalGEN=CountRecrdSt($state=$row['state'],$field='areaOfInterest',$value='Chemistry');
$grandTotalGEN=$totalGEN+$grandTotalGEN;
$total6=CountRecrdSt($state=$row['state'],$field='areaOfInterest',$value='Mathematics');
$grandTotal6=$total6+$grandTotal6;
$total7=CountRecrdSt($state=$row['state'],$field='areaOfInterest',$value='Biological Sciences');
$grandTotal7=$total7+$grandTotal7;
$total8=CountRecrdSt($state=$row['state'],$field='areaOfInterest',$value='Engineering');
$grandTotal8=$total8+$grandTotal8;
$total9=CountRecrdSt($state=$row['state'],$field='areaOfInterest',$value='Others' );
$grandTotal9=$total9+$grandTotal9;
?>
<?php }}else{?>
<tr>
<td align="center" colspan='13' class="error">Sorry,No Record Found</td>
</tr>
<?php }?>
<tr>
<td align="right" colspan='13' class="error"><hr></td>
</tr>
<tr class="">
<td align="center" class="error">Grand Total: </td>
<td align="center" ><?php echo $grandTotalM+CountRecrdSt($state=0,$field='gender',$value='0');?></td>
<td align="center" ><?php echo $grandTotalF+CountRecrdSt($state=0,$field='gender',$value='1');?></td>
<td align="center" ><?php echo $grandTotal2+CountRecrdSt($state=0,$field='participantStatus',$value='0');?></td>
<td align="center" ><?php echo $grandTotal3+CountRecrdSt($state=0,$field='participantStatus',$value='1');?></td>
<td align="center" ><?php echo $grandTotalOBC+CountRecrdSt($state=0,$field='areaOfInterest',$value='Physics');?></td>
<td align="center" ><?php echo $grandTotalGEN+CountRecrdSt($state=0,$field='areaOfInterest',$value='Chemistry');?></td>
<td align="center" ><?php echo $grandTotal6+CountRecrdSt($state=0,$field='areaOfInterest',$value='Mathematics');?></td>
<td align="center" ><?php echo $grandTotal7+CountRecrdSt($state=0,$field='areaOfInterest',$value='Biological Sciences');?></td>
<td align="center" ><?php echo $grandTotal8+CountRecrdSt($state=0,$field='areaOfInterest',$value='Engineering');?></td>
<td align="center" ><?php echo $grandTotal9+CountRecrdSt($state=0,$field='areaOfInterest',$value='Others');?></td>
<td align="center" ><?php echo $grandTotal+CountRecrdSt($state=0,$field='',$value='');?></td>
</tr>
</table>
</td>
</tr>
<?php $sql="Select Distinct(state) from tbl_record ";
$query=mysql_query($sql);
?>
<tr>
<td valign="top"><table width="100%" cellpadding="2" cellspacing="2" border="1">
<tr >
<td colspan="13" align="center" >Data By Category ( in Numbers ) </td>
</tr>
<tr >
<td width="13%" align="center" >Data Feed By</td>
<td colspan="9" align="center" >Category</td>
<td width="9%" align="center" > </td>
</tr>
<tr >
<td align="center" >State</td>
<td width="6%" align="center" >Gen</td>
<td width="6%" align="center" >SC</td>
<td width="6%" align="center" >ST</td>
<td width="6%" align="center" >PH</td>
<td width="7%" align="center" >SN</td>
<td width="6%" align="center" >NR</td>
<td width="7%" align="center" >OB</td>
<td width="9%" align="center" >NRI</td>
<td width="10%" align="center" >Others</td>
<td align="center" >Total</td>
</tr>
<?php if(mysql_num_rows($query)>0)
{
$grandTotal=0;
$total=0;
$grandTotal=0;
$total=0;
$grandTotalM=0;
$totalM=0;
$grandTotalF=0;
$totalF=0;
$grandTotal2=0;
$total2=0;
$grandTotal3=0;
$total3=0;
$grandTotalOBC=0;
$totalOBC=0;
$grandTotalGEN=0;
$totalGEN=0;
$grandTotal6=0;
$total6=0;
$grandTotal7=0;
$total7=0;
$grandTotal8=0;
$total8=0;
$grandTotal9=0;
$total9=0;
$grandTotal10=0;
$total10=0;
?>
<?php while($row=mysql_fetch_array($query))
{
//print_r($row);
?>
<tr>
<td align="center" ><?php echo $row['state']?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'category','1');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'category','2');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'category','3');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'category','4');?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'category',5);?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'category',6);?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'category',7);?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'category',8);?></td>
<td align="center" ><?php echo CountRecrdSt($row['state'],'category',9);?></td>
<td align="center" ><?php echo CountRecrdSt($state=$row['state'],$field='',$value='');?></td>
</tr>
<?php
$total=CountRecrdSt($state=$row['state'],$field='',$value='');
$grandTotal=$total+$grandTotal;
$totalM=CountRecrdSt($state=$row['state'],$field='gender',$value='0');
$grandTotalM=$totalM+$grandTotalM;
$totalF=CountRecrdSt($state=$row['state'],$field='gender',$value='1');
$grandTotalF=$totalF+$grandTotalF;
$total2=CountRecrdSt($state=$row['state'],$field='category',$value='2');
$grandTotal2=$total2+$grandTotal2;
$total3=CountRecrdSt($state=$row['state'],$field='category',$value='3');
$grandTotal3=$total3+$grandTotal3;
$totalOBC=CountRecrdSt($state=$row['state'],$field='category',$value='4');
$grandTotalOBC=$totalOBC+$grandTotalOBC;
$totalGEN=CountRecrdSt($state=$row['state'],$field='category',$value='1');
$grandTotalGEN=$totalGEN+$grandTotalGEN;
$total6=CountRecrdSt($state=$row['state'],$field='category',$value=5);
$grandTotal6=$total6+$grandTotal6;
$total7=CountRecrdSt($state=$row['state'],$field='category',$value=6);
$grandTotal7=$total7+$grandTotal7;
$total8=CountRecrdSt($state=$row['state'],$field='category',$value=7);
$grandTotal8=$total8+$grandTotal8;
$total9=CountRecrdSt($state=$row['state'],$field='category',$value=8 );
$grandTotal9=$total9+$grandTotal9;
$total10=CountRecrdSt($state=$row['state'],$field='category',$value=9);
$grandTotal10=$total10+$grandTotal10;
?>
<?php }}else{?>
<tr>
<td align="center" colspan='13' class="error">Sorry,No Record Found</td>
</tr>
<?php }?>
<tr>
<td align="right" colspan='13' class="error"><hr></td>
</tr>
<tr class="">
<td align="center" class="error">Grand Total: </td>
<td align="center" ><?php echo $grandTotalGEN+CountRecrdSt($state=0,$field='category',$value='1');?></td>
<td align="center" ><?php echo $grandTotal2+CountRecrdSt($state=0,$field='category',$value='2');?></td>
<td align="center" ><?php echo $grandTotal3+CountRecrdSt($state=0,$field='category',$value='3');?></td>
<td align="center" ><?php echo $grandTotalOBC+CountRecrdSt($state=0,$field='category',$value='4');?></td>
<td align="center" ><?php echo $grandTotal6+CountRecrdSt($state=0,$field='category',$value='5');?></td>
<td align="center" ><?php echo $grandTotal7+CountRecrdSt($state=0,$field='category',$value='6');?></td>
<td align="center" ><?php echo $grandTotal8+CountRecrdSt($state=0,$field='category',$value='7');?></td>
<td align="center" ><?php echo $grandTotal9+CountRecrdSt($state=0,$field='category',$value='8');?></td>
<td align="center" ><?php echo $grandTotal10+CountRecrdSt($state=0,$field='category',$value='9');?></td>
<td align="center" ><?php echo $grandTotal+CountRecrdSt($state=0,$field='',$value='');?></td>
</tr>
</table>
</td>
</tr>
<?php $sql="Select Distinct(B.countryId) from tbl_forrecord A, tbl_country B where A.countryId=B.countryId ";
$query=mysql_query($sql);?>
<tr>
<td valign="top">
<table width="100%" cellpadding="2" cellspacing="2" border="1">
<tr >
<td colspan="13" align="center" >Data By Country ( in Numbers ) </td>
</tr>
<tr >
<td width="13%" align="center" >Country Name </td>
<td colspan="2" align="center" >Gender</td>
<td colspan="2" align="center" >Participation Status </td>
<td colspan="6" align="center">Subject</td>
<td width="9%" align="center" > </td>
</tr>
<tr >
<td align="center" > </td>
<td width="7%" align="center" >Male</td>
<td width="8%" align="center" >Female</td>
<td width="6%" align="center" >Student</td>
<td width="6%" align="center" >Teacher</td>
<td width="6%" align="center" >Physics</td>
<td width="6%" align="center" >Chemistry</td>
<td width="7%" align="center" >Mathematics</td>
<td width="6%" align="center" >Bio. Sc. </td>
<td width="7%" align="center" >Engineering</td>
<td width="9%" align="center" >Others</td>
<td width="10%" align="center" >Total</td>
</tr>
<?php if(mysql_num_rows($query)>0)
{
$grandTotal=0;
$total=0;
$grandTotal=0;
$total=0;
$grandTotalM=0;
$totalM=0;
$grandTotalF=0;
$totalF=0;
$grandTotal2=0;
$total2=0;
$grandTotal3=0;
$total3=0;
$grandTotalOBC=0;
$totalOBC=0;
$grandTotalGEN=0;
$totalGEN=0;
$grandTotal6=0;
$total6=0;
$grandTotal7=0;
$total7=0;
$grandTotal8=0;
$total8=0;
$grandTotal9=0;
$total9=0;
$grandTotal10=0;
$total10=0;
?>
<?php while($row=mysql_fetch_array($query))
{
//print_r($row);
?>
<tr>
<td align="center" ><?php echo getUserName($row['countryId'])?></td>
<td align="center" ><?php echo CountRecrd($row['countryId'],'gender','0');?></td>
<td align="center" ><?php echo CountRecrd($row['countryId'],'gender','1');?></td>
<td align="center" ><?php echo CountRecrd($row['countryId'],'participantStatus','0');?></td>
<td align="center" ><?php echo CountRecrd($row['countryId'],'participantStatus','1');?></td>
<td align="center" ><?php echo CountRecrd($row['countryId'],'areaOfInterest','Physics');?></td>
<td align="center" ><?php echo CountRecrd($row['countryId'],'areaOfInterest','Chemistry');?></td>
<td align="center" ><?php echo CountRecrd($row['countryId'],'areaOfInterest','Mathematics');?></td>
<td align="center" ><?php echo CountRecrd($row['countryId'],'areaOfInterest','Biological Sciences');?></td>
<td align="center" ><?php echo CountRecrd($row['countryId'],'areaOfInterest','Engineering');?></td>
<td align="center" ><?php echo CountRecrd($row['countryId'],'areaOfInterest','Others');?></td>
<td align="center" ><?php echo CountRecrd($countryId=$row['countryId'],$field='',$value='');?></td>
</tr>
<?php
$total=CountRecrd($countryId=$row['countryId'],$field='',$value='');
$grandTotal=$total+$grandTotal;
$totalM=CountRecrd($countryId=$row['countryId'],$field='gender',$value='0');
$grandTotalM=$totalM+$grandTotalM;
$totalF=CountRecrd($countryId=$row['countryId'],$field='gender',$value='1');
$grandTotalF=$totalF+$grandTotalF;
$total2=CountRecrd($countryId=$row['countryId'],$field='participantStatus',$value='0');
$grandTotal2=$total2+$grandTotal2;
$total3=CountRecrd($countryId=$row['countryId'],$field='participantStatus',$value='1');
$grandTotal3=$total3+$grandTotal3;
$totalOBC=CountRecrd($countryId=$row['countryId'],$field='areaOfInterest',$value='Physics');
$grandTotalOBC=$totalOBC+$grandTotalOBC;
$totalGEN=CountRecrd($countryId=$row['countryId'],$field='areaOfInterest',$value='Chemistry');
$grandTotalGEN=$totalGEN+$grandTotalGEN;
$total6=CountRecrd($countryId=$row['countryId'],$field='areaOfInterest',$value='Mathematics');
$grandTotal6=$total6+$grandTotal6;
$total7=CountRecrd($countryId=$row['countryId'],$field='areaOfInterest',$value='Biological Sciences');
$grandTotal7=$total7+$grandTotal7;
$total8=CountRecrd($countryId=$row['countryId'],$field='areaOfInterest',$value='Engineering');
$grandTotal8=$total8+$grandTotal8;
$total9=CountRecrd($countryId=$row['countryId'],$field='areaOfInterest',$value='Others' );
$grandTotal9=$total9+$grandTotal9;
?>
<?php }}else{?>
<tr>
<td align="center" colspan='13' class="error">Sorry,No Record Found</td>
</tr>
<?php }?>
<tr>
<td align="right" colspan='13' class="error"><hr></td>
</tr>
<tr class="">
<td align="center" class="error">Grand Total: </td>
<td align="center" ><?php echo $grandTotalM+CountRecrd($countryId=0,$field='gender',$value='0');?></td>
<td align="center" ><?php echo $grandTotalF+CountRecrd($countryId=0,$field='gender',$value='1');?></td>
<td align="center" ><?php echo $grandTotal2+CountRecrd($countryId=0,$field='participantStatus',$value='0');?></td>
<td align="center" ><?php echo $grandTotal3+CountRecrd($countryId=0,$field='participantStatus',$value='1');?></td>
<td align="center" ><?php echo $grandTotalOBC+CountRecrd($countryId=0,$field='areaOfInterest',$value='Physics');?></td>
<td align="center" ><?php echo $grandTotalGEN+CountRecrd($countryId=0,$field='areaOfInterest',$value='Chemistry');?></td>
<td align="center" ><?php echo $grandTotal6+CountRecrd($countryId=0,$field='areaOfInterest',$value='Mathematics');?></td>
<td align="center" ><?php echo $grandTotal7+CountRecrd($countryId=0,$field='areaOfInterest',$value='Biological Sciences');?></td>
<td align="center" ><?php echo $grandTotal8+CountRecrd($countryId=0,$field='areaOfInterest',$value='Engineering');?></td>
<td align="center" ><?php echo $grandTotal9+CountRecrd($countryId=0,$field='areaOfInterest',$value='Others');?></td>
<td align="center" ><?php echo $grandTotal+CountRecrd($countryId=0,$field='',$value='');?></td>
</tr>
</table>
</td>
</tr>
</table>