ถามเรื่อง code หน่อยคับคือต้องการให้มันเอาค่าในช่องที่ใส่ไปเป็นตัวค้นหารวมด้วยกับ code เดิม
ออกแบบตารางไว้ยังไงบ้างครับ ลอง Capture มาดูหน่อยครับ
Date :
2013-02-22 16:38:34
By :
mr.win
อันนี้ตารางข้อมูลคับ
อันนี้codeทั้งหมดของหน้านี้คับ
ช่วยดูให้ทีคับ
Code (PHP)
<?php require_once('Connections/employee.php'); ?>
<?php
mysql_select_db($database_employee, $employee);
$profile_id = $_GET['profile_id'];
$query_holiday_t1 = "SELECT COUNT(*) FROM holiday WHERE holiday_t = N'ลาป่วย' AND profile_id=".$profile_id;
$holiday_t1 = mysql_query($query_holiday_t1, $employee) or die(mysql_error());
$row_holiday_t1 = mysql_fetch_assoc($holiday_t1);
$totalRows_holiday_t1 = mysql_num_rows($holiday_t1);
mysql_select_db($database_employee, $employee);
$profile_id = $_GET['profile_id'];
$query_holiday_t2 = "SELECT COUNT(*) FROM holiday WHERE holiday_t = N'ลากิจ' AND profile_id=".$profile_id;
$holiday_t2 = mysql_query($query_holiday_t2, $employee) or die(mysql_error());
$row_holiday_t2 = mysql_fetch_assoc($holiday_t2);
$totalRows_holiday_t2 = mysql_num_rows($holiday_t2);
mysql_select_db($database_employee, $employee);
$profile_id = $_GET['profile_id'];
$query_holiday_t3 = "SELECT COUNT(*) FROM holiday WHERE holiday_t = N'ลาพักผ่อน' AND profile_id=".$profile_id;
$holiday_t3 = mysql_query($query_holiday_t3, $employee) or die(mysql_error());
$row_holiday_t3 = mysql_fetch_assoc($holiday_t3);
$totalRows_holiday_t3 = mysql_num_rows($holiday_t3);
mysql_select_db($database_employee, $employee);
$profile_id = $_GET['profile_id'];
$query_holiday_t4 = "SELECT COUNT(*) FROM holiday WHERE holiday_t = N'มาสาย' AND profile_id=".$profile_id;
$holiday_t4 = mysql_query($query_holiday_t4, $employee) or die(mysql_error());
$row_holiday_t4 = mysql_fetch_assoc($holiday_t4);
$totalRows_holiday_t4 = mysql_num_rows($holiday_t4);
mysql_select_db($database_employee, $employee);
$profile_id = $_GET['profile_id'];
$query_holiday_t5 = "SELECT COUNT(*) FROM holiday WHERE holiday_t = N'ขาดราชการ' AND profile_id=".$profile_id;
$holiday_t5 = mysql_query($query_holiday_t5, $employee) or die(mysql_error());
$row_holiday_t5 = mysql_fetch_assoc($holiday_t5);
$totalRows_holiday_t5 = mysql_num_rows($holiday_t5);
mysql_select_db($database_employee, $employee);
$profile_id = $_GET['profile_id'];
$query_holiday_t6 = "SELECT COUNT(*) FROM holiday WHERE holiday_t = N'ลาศึกษาต่อ' AND profile_id=".$profile_id;
$holiday_t6 = mysql_query($query_holiday_t6, $employee) or die(mysql_error());
$row_holiday_t6 = mysql_fetch_assoc($holiday_t6);
$totalRows_holiday_t6 = mysql_num_rows($holiday_t6);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/userstemplates.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>คณะบริหารธุรกิจ เศรษฐศาสตร์และการสื่อสาร</title>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
body {
background-color: #F0F0F0;
}
-->
</style>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body topmargin="0">
<table width="200" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" align="center" valign="middle" bgcolor="#FFFFFF"><img src="images/background_01_03.jpg" width="1008" height="125" border="0" usemap="#Map3" /></td>
</tr>
<tr>
<td width="157" align="left" valign="top" bgcolor="#FFFFFF"><p><img src="images/Untitled-1_03.jpg" width="157" height="51" border="0" usemap="#Map" /></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p></td>
<td width="851" align="left" valign="top" bgcolor="#FFFFFF"><!-- InstanceBeginEditable name="EditRegion2" -->
<table border="1">
<tr>
<td width="100" bgcolor="#999999"><div align="center">ปีงบประมาณ</div></td>
<td width="100" bgcolor="#999999"><div align="center">ลาป่วย</div></td>
<td width="100" bgcolor="#999999"><div align="center">ลากิจ</div></td>
<td width="100" bgcolor="#999999"><div align="center">ลาพักผ่อน</div></td>
<td width="100" bgcolor="#999999"><div align="center">มาสาย</div></td>
<td width="100" bgcolor="#999999"><div align="center">ขาดราชการ</div></td>
<td width="100" bgcolor="#999999"><div align="center">ลาศึกษาต่อ</div></td>
</tr>
<tr>
<td><div align="center">
<input name="Search" type="text" size="20" />
<input type="submit" name="Submit" value="ค้นหา">
</div></td>
<td><div align="center"><?php echo $row_holiday_t1['COUNT(*)']; ?></div></td>
<td><div align="center"><?php echo $row_holiday_t2['COUNT(*)']; ?></div></td>
<td><div align="center"><?php echo $row_holiday_t3['COUNT(*)']; ?></div></td>
<td><div align="center"><?php echo $row_holiday_t4['COUNT(*)']; ?></div></td>
<td><div align="center"><?php echo $row_holiday_t5['COUNT(*)']; ?></div></td>
<td><div align="center"><?php echo $row_holiday_t6['COUNT(*)']; ?></div></td>
</tr>
</table>
<!-- InstanceEndEditable --></td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle" bgcolor="#F0F0F0"><img src="images/bec.jpg" width="960" height="96" border="0" usemap="#Map2" /></td>
</tr>
</table>
<map name="Map" id="Map"><area shape="rect" coords="44,10,115,39" href="indexhome.php" />
</map>
<map name="Map2" id="Map2"><area shape="rect" coords="869,39,916,71" href="http://www.youtube.com" />
<area shape="rect" coords="840,39,864,67" href="http://www.facebook.com" />
<area shape="rect" coords="805,40,837,69" href="http://www.twitter.com" />
</map>
<map name="Map3" id="Map3"><area shape="rect" coords="69,17,704,111" href="http://www.bec.nu.in.th" />
</map></body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($holiday_t1);
?>
Date :
2013-02-22 22:21:58
By :
nubc
น่าจะใช้การ SUM แล้ว GROUP BY ได้น่ะครับ
Date :
2013-02-23 07:24:49
By :
mr.win
ลองเข้าไปในบทความครับเกี่ยวกับ SQL GROUP BY ครับ
Date :
2013-02-23 18:23:19
By :
mr.win
Load balance : Server 03