需要帮助以使良好的SQL查询 [英] need help to make good sql query
本文介绍了需要帮助以使良好的SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
我正在休假日历,已经使用日历制作了日历...
进行一些更改,在php中找到更多的功能,这使事情变得很容易...
但需要帮助以进行良好的sql查询以显示数据并进行比较.
现在很困惑,如果我将SQL查询放入循环中,将花费大量时间来比较和显示数据...什么是对此的最佳解决方案...
请立即帮助....
hi
i am making a leave calendar i have made the calendar ...using this code
make some changes find few more functions in php which make things lot easy ...
but need help to make a good sql query to show data and compare them.
now confused where to put sql query if i put in the loops it will take lots of time to compare and show data ...what can be the best solution for this ...
plz help now ....
<pre lang="php">$sql ="SELECT leave_date,leave_status,leave_type_id FROM `hs_hr_leave` WHERE employee_id = $emplid ";
$res = mysql_query($sql);
while ($row = mysql_fetch_array($res, MYSQL_NUM)) {
echo "<tr>";
echo ''<td>''.$row[0].''</td><br/>'';
echo "<td>".$row[1]."</td><br/>";
echo "<td>".$row[2]."</td><br/>";
echo "</tr>";
}
<<pre lang="xml">?php
if (isset($emplistshow) && ($emplistshow == ''show'')) {
$monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
?>
<div class="outerbox" style=" float: left;">
<table colspan="5" rowspan="4">
<tr >
<td width="18%" colspan="2"><strong>Month</strong></td>
<td width="12%" colspan="2"><strong>Division</strong></td>
<?php for($m=1;$m <=31;$m++) { ?>
<td width="26" height="20px" align="center" valign="middle" ><?php echo $m; ?></td>
<?php } ?>
</tr>
</table>
</div>
<div class="outerbox" style=" float: left;">
<table >
<?php for($Month=1;$Month <= 12;) { ?>
<tr>
<td width="18%" colspan="2"><strong><?php echo $monthNames[$Month-1]; ?></strong></td>
<td width="12%" colspan="2"><strong>Division</strong></td>
<?php
$num = cal_days_in_month(CAL_GREGORIAN, $Month, $cYear); // 31
//$dates = date("$cYear-$Month-1");
for($i=1;$i<=$num;$i++)
{ $dates = date("$cYear-$Month-$i");
//echo $dates.''<br/>'';
echo "<td width=''26'' height=''20px'' align=''center'' valign=''middle'' >".$i."</td>";
}
//echo "<br/>";
$Month++;
}
?>
</tr>
</table>
<?php } ?>
推荐答案
sql ="SELECT Leave_date,leave_status,leave_type_id FROM`hs_hr_leave` WHERE employee_id =
sql ="SELECT leave_date,leave_status,leave_type_id FROM `hs_hr_leave` WHERE employee_id =
emplid";
res = mysql_query(
res = mysql_query(
这篇关于需要帮助以使良好的SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文