|
|
|
เขียนโค๊ด php เขาทำกัยอย่างไร จะรู้ได้ยังไงว่าข้อความที่ใส่นั้นถูก |
|
|
|
|
|
|
|
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
}
.mstyle2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
}ss
.style2 {font-family: "Angsana New"}
.style18 {font-family: "mS Sans Serif"}
.style50 {font-family: "mS Sans Serif"; font-size: x-small; }
.style51 {font-size: x-small}
.style52 {font-family: "mS Sans Serif"; font-size: small; }
.style53 {font-family: "mS Sans Serif"; font-size: smaller; }
.style57 {font-family: "mS Sans Serif"; font-size: x-small; font-weight: bold; }
.style61 {font-family: "Angsana New"; font-size: 20px; }
-->
</style>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<?php
$dayweek = array(1 => "Sunday",
2 => "Monday",
3 => "Tuesday",
4 => "Wednesday",
5 => "Thursday",
6 => "Friday",
7 => "Saturday");
$dayweekThai = array(1 => "วันอาทิตย์",
2 => "วันจันทร์",
3 => "วันอังคาร",
4 => "วันพุธ",
5 => "วันพฤหัส",
6 => "วันศุกร์",
7 => "วันเสาร์");
function showtime($getleveltime) // input
{
switch($getleveltime)
{
case '1' : $showtime ="08:00:00"; break;
case '2' : $showtime ="08:50:00"; break;
case '3' : $showtime ="09:40:00"; break;
case '4' :$showtime ="10:30:00"; break;
case '5' :$showtime ="11:20:00"; break;
case '6' :$showtime ="12:10:00"; break;
case '7' :$showtime ="13:10:00"; break;
case '8' :$showtime ="14:00:00"; break;
case '9' :$showtime ="14:50:00"; break;
case '10' :$showtime ="15:40:00"; break;
case '11' :$showtime ="16:30:00"; break;
case '12' :$showtime ="17:20:00"; break;
case '13' :$showtime ="18:10:00"; break;
case '14' :$showtime ="19:00:00"; break;
case '15' :$showtime ="19:50:00"; break;
}
return $showtime;
}
function timeennrolloff($getleveltime) // input
{
switch($getleveltime)
{
case '1' :$showtime = "08:50:00"; break;
case '2' :$showtime ="09:40:00"; break;
case '3' :$showtime ="10:30:00"; break;
case '4' :$showtime ="11:20:00"; break;
case '5' :$showtime ="12:10:00"; break;
case '6' :$showtime ="13:10:00"; break;
case '7' :$showtime ="14:00:00"; break;
case '8' :$showtime ="14:50:00"; break;
case '9' :$showtime ="15:40:00"; break;
case '10' :$showtime ="16:30:00"; break;
case '11' :$showtime ="17:20:00"; break;
case '12' :$showtime ="18:10:00"; break;
case '13' :$showtime ="19:00:00"; break;
case '14' :$showtime ="19:50:00"; break;
case '15' :$showtime ="20:40:00"; break;
}
return $showtime;
}
Function Datediff($datefrom,$dateto)
{
$startDate = strtotime($datefrom);
$lastDate = strtotime($dateto);
$differnce = $startDate - $lastDate;
// $differnce = ($differnce / (60*60*24)); //???????????????? return ????????????????
return $differnce;
}
function dayofweek($datestr)
{
$datearr = explode("-", $datestr);
$datestamp=mktime(0,0,0,$datearr[1],$datearr[2],$datearr[0]);
$date = getdate($datestamp);
$dayofweek = $date["weekday"];
return $dayofweek;
}
//
global $config,$usersess,$comm,$lang,$dataset,$picUpload,$file;
require_once("header.inc");
require_once ("config.inc.php");
require_once ("include/variables.inc.php");
// ??????? ???? ----------------------------------------------------------------------------
require_once ("global.inc.php");
require_once ("include/mysql.inc.php");
require_once("include/myclass/mclasses.inc.php"); // Call my Class
require_once("include/myclass/dataset.inc.php"); // Call Data Base
require_once("include/myclass/components.inc.php"); // Call Data Base
$stuid = $_GET['stuid'];
$classid = $_GET['classid'];
///
$Tstudentid = db_getvar('studentmaster',"STUDENTCODE=$studentid","STUDENTID");
@mysql_connect($host,$user,$pwd); // ?????????
$sql_temp = "
SELECT `enrollitem`.studentid, `enrollitem`.classid, `classtimetable`.WEEKDAY,
`classtimetable`.TIMEPERIODFROM, `classtimetable`.TIMEPERIODTO
FROM db_mscconsule.enrollitem `enrollitem`
INNER JOIN
db_mscconsule.classtimetable `classtimetable`
ON (`enrollitem`.classid = `classtimetable`.CLASSID) ";
$sql_temp .= " where enrollitem.classid ='$classid' and studentid = '$Tstudentid' ";
$result=mysql_db_query($dbname,$sql_temp);
$NRow=mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
$WEEKDAY = $row["WEEKDAY"] ;
$TIMEPERIODFROM = $row["TIMEPERIODFROM"] ;
$TIMEPERIODTO = $row["TIMEPERIODTO"] ;
}
$TIMEstart = showtime($TIMEPERIODFROM);
$TIMEend = showtime($TIMEPERIODTO);
echo "<TABLE align=center cellSpacing=0 cellPadding=0 width=98% border=0 bgcolor=#686898>";
echo "<TR><TD> <font color=#FFFFFF><b>ชื่อนักศึกษา:$dayweekThai[$WEEKDAY] </b></Font> </TD></TR> ";
echo "<TR><TD> <font color=#FFFFFF><b>:$TIMEPERIODFROM แสดงเวลาเข้า [$TIMEstart] </b></Font> </TD></TR> ";
echo "<TR><TD> <font color=#FFFFFF><b> :$TIMEPERIODTOแสดงเวลาออก [$TIMEend] </b></Font> </TD></TR> ";
// ????????????
@mysql_connect($host,$user,$pwd);
$sql = "
SELECT `userinfo`.studentid, `checkinout`.CHECKTIME
FROM db_mscconsule.userinfo `userinfo`
INNER JOIN
db_mscconsule.checkinout `checkinout`
ON (`userinfo`.USERID = `checkinout`.USERID) ";
$sql .= " where studentid ='$studentid' order by CHECKTIME asc ";
mysql_query("SET NAMES TIS620");
$result=mysql_db_query($dbname,$sql);
$NRow=mysql_num_rows($result);
// ????????
echo "<TABLE align=center cellSpacing=0 cellPadding=0 width=98% border=0 bgcolor=#000000>";
echo "<TR><TD>";
echo "<table width='100%' border=0 cellpadding=3 cellspacing=1 align='center'>";
echo "<tr bgcolor=#686898>";
echo "<td align=center width=9%><font color=#FFFFFF><b>]NO</b></font></td>\n";
echo "<td align=center width=15%><font color=#FFFFFF><b>รหัสวิชา</b></font></td>\n";
echo "<td align=center width=15%><font color=#FFFFFF><b>ชื่อวิชา</b></font></td>\n";
echo "<td align=center width=15%><font color=#FFFFFF><b>ผู้สอน</b></font></td>\n";
echo "<td align=center width=25%><font color=#FFFFFF><b>กลุ่มเรียน</b> </font></td>\n";
echo "</tr>\n\n";
$n = 1;
while ($row = mysql_fetch_array($result)) {
$bgc = ($bgc=="#FAF2E6") ? "#FFFFCC" : "#FAF2E6";
$No = sprintf("%05d",$n);
$Day = trim(substr($row["CHECKTIME"],0,10)); // ??????????????
$time = trim(substr($row["CHECKTIME"],11,10)); // ??????????????
//$Name = $row["COURSENAME"];
$Reply = $row["Reply"];
// ??????????????????
#$ReplyDate = substr($row["ReplyDate"],0,11); // ????????????
//$dayofweek = date( 'w', $row["CHECKTIME"]);
$Mdayofweek = dayofweek($Day);
if ($dayweek[$WEEKDAY] == $Mdayofweek ) {
$n = $n +1;
// check ??????
// check ???????
echo "<tr bgColor=$bgc><td><center><a href='showtable.php'>",$No,"</a></center></td>";
echo "<td><center>",$Day,"</center></td>";
echo "<td><center>[$time]<center></td>"; // ???????
echo "<td><center>[$time]<center></td>"; // ????????
$Caclutime = Datediff($time,$TIMEstart); // ???? ??
$mCac = $Caclutime/60; // ???????????? // ????? ? 15 ?????????????????? ???????
if( $mCac <= 15 )
{
$note = "???????? ".$mCac.'????';
} elseif ( $mCac >= 30 )
{
$note = "??? ??????????????? 30 ??????????? ".$mCac.'????';
}
echo "<td><center>$note<center></td></TR>";
}
}
echo "</table>\n";
echo "</TD></TR>\n";
echo "</TABLE>\n";
?>
Tag : PHP
|
|
|
|
|
|
Date :
2011-04-22 11:13:47 |
By :
นักศึกษา |
View :
636 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่เข้าใจคำถาม
แต่เดาตอบว่า อยากรู้ว่าข้อความที่ใส่นั้น ถูกหรือไม่ถูก
ให้ ECHO ตัวแปรดูข้อมูลก่อนเก็บเข้า db ครับ
|
|
|
|
|
Date :
2011-04-22 11:16:23 |
By :
deawx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|