|
|
|
โคดในการเลือข็อมูลมาใส่ค่ะ แล้วปรากฏว่า ส่วนของการเลือข้อมูลจาก id_username ใน working หายค่ะ ช่วยหน่อนค่ะ |
|
|
|
|
|
|
|
พอดีเราลองเอาโคดในการเลือข็อมูลมาใส่ค่ะ แล้วปรากฏว่า ส่วนของการเลือข้อมูลจาก id_username ใน working หายค่ะ ชื่อ user ก็ไม่ขึ้น ช่วยหน่อยค่ะ
config_server.php
Code (PHP)
<?php
date_default_timezone_set('Asia/Bangkok');
$host="localhost"; //ชื่อโฮส
$db_username="root"; //ชื่อผู้ใช้
$db_password="1234"; //รหัสผ่าน
$dbname="graphic"; //ชื่อฐานข้อมูล
$connect = mysql_connect($host,$db_username,$db_password);
mysql_query("SET NAMES UTF8"); // เพิ่มบรรทัดนี้เขามา ตามที่คุณแนะนำมา
//* mysql_query("SET NAMES UTF8");
if (mysqli_connect_errno()){
echo "ไม่สามารถติดต่อฐานข้อมูลได้"; exit();
}
//*** Reject user not online
$intRejectTime = 20; // Minute
$sql = "UPDATE user SET LoginStatus = '0', LastUpdate = '0000-00-00 00:00:00' WHERE 1 AND DATE_ADD(LastUpdate, INTERVAL $intRejectTime MINUTE) <= NOW() ";
?>
login (test.php)
Code (PHP)
<?
error_reporting(0);
session_start();
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login & Password</title>
<? include("config_server.php");?>
<style type="text/css">
body {
background-image: url(img/web.jpg);
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>
<center>
<img src="img/Untitled-1-01.png" width="1062" height="313" />
</center>
<div>
<form id="form1" name="form1" method="post" action="test.php">
<br />
<br />
<table width="335" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td width="29"></td>
<td width="83" align="left">Username</td>
<td width="211" align="left"><input type="text" name="USER" id="USER" class="textbox1"/></td>
</tr>
<tr>
<td></td>
<td align="left">Password</td>
<td align="left"><label for="PASSWORD"></label>
<input type="password" name="PASSWORD" id="PASSWORD" class="textbox1"/></td>
</tr>
<tr>
<td> </td>
<td align="left" valign="top"> </td>
<td align="left"><input type="submit" name="OK" id="OK" value="LOGIN " class="button1" /></td>
</tr>
</table>
</form>
</div>
<?
$USER=$_POST['USER'];
$PASSWORD=$_POST['PASSWORD'];
if($PASSWORD <>'')
{
$sql = "select * from user where username='" . $USER . "' AND password='" . $PASSWORD . "'";
$dbquery = mysql_db_query($dbname, $sql);
$rec= mysql_num_rows($dbquery);
if ($rec==1){
while($result = mysql_fetch_array($dbquery)) {
$_SESSION['username']=$result['username'];
$_SESSION['password']=$result['password'];
$_SESSION['id_username']=$result['id_username'];
}
$_SESSION['CHECK_USER'] ="yes";
echo '<script type="text/javascript"> window.location="mainworking.php" </script>';
} else {
echo '<script>alert("กรุณาใส่สหัสของท่านให้ถูกต้อง");</script>';
}
}
mainworking.php
Code (PHP)
<?php
error_reporting(0);
session_start();
require_once("config_server.php");
if(!isset($_SESSION['id_username']))
{
echo "<script>alert('กรุณาลงชื่อเข้าระบบ'); window.location='index.php';</script>";
exit();
}
else{
//*** Update Last Stay in Login System
$sql = "UPDATE user SET LastUpdate = NOW() WHERE id_username = '".$_SESSION['id_username']."' ";
$query = mysqli_query($con,$sql);
mysql_query("SET NAMES UTF8");
//*** Get User Login
$sql= "SELECT * FROM user WHERE id_username = '".$_SESSION['id_username']."' ";
$dbquery = mysql_db_query($dbname, $sql);
$result1 = mysqli_fetch_array($result1,MYSQLI_ASSOC);
$sql= "SELECT * FROM working "; //ชื่อตาราง
$query = mysql_query($sql) or die ("Error Query [".$sql."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 10; // Per Page
if(!$_GET["Page"]=0)
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$sql.=" order by id_work ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($sql)or die ("Error Query [".$sql."]");
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Main Working</title>
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-image: url(img/web.jpg);
}
</style>
<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
<script language="javascript">
function CheckConfirm(){
if (confirm('กรุณายืนยันการลบข้อมูล !!!!')){
return true;
}else {
return false;
}
}
</script>
<script type="text/javascript">
function OK() {
var status = document.getElementById('status').value; //-- เก็บค่าตัวแปล ---/
if (status !=''){var status1 = "&status=" + status} //*** จรวจสอบว่า text ..Status =ช่องว่างหรือไม่
window.location="mainworking.php?"+ status1
}
</script>
</head>
<body onLoad="MM_preloadImages('img/logout2.png','img/plus-icon1.png','img/edit1.png','img/Detele1.png')">
<tr>
<td bgcolor="#FFCCFF">
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<br>
<br>
<table width="1024" border="0" align="center" cellpadding="1" cellspacing="0">
<tr>
<td height="302" align="center"><p><img src="img/Untitled-1-01.png" width="1024" height="300"></p></td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFFFF"><br>
<br>
<table width="990" border="0" align="center">
<tr>
<td width="885"><strong>ยินดีต้อนรับ :</strong>
<?=$result1["username"];?>
</td>
<td width="150"><a href="logout.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','img/logout2.png',1)"><img src="img/logout.png" width="150" height="40" id="Image1"></a></td>
</tr>
</table>
<br>
<table width="840" border="0" cellspacing="0" cellpadding="1">
<tr>
<td height="30" valign="middle">
<select name="status" id="status" onChange="OK();" >
<option value="">--- เลือก ---</option>
<option value="Working">Working</option>
<option value="Have not done">Have not done</option>
<option value="Cancel">Cancel</option>
<option value="complete">complete</option>
</select>
<a href="event.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('insert','','img/plus-icon1.png',1)"> <img src="img/plus-icon.png" width="29" height="29" id="insert"></a></p>
</form></td>
</tr>
</table>
<form name="form1" method="post" action="<?=$_POST['status'];?>" >
<table width="1009" border="2" align="center" cellpadding="1" cellspacing="1" bordercolordark="#FF3333" id="webboard">
<tr>
<th width="67" height="41" bgcolor="#FFFFCC"> <div align="center">
<p>รหัสงาน</p>
</div></th>
<th width="112" bgcolor="#FFFFCC"> <div align="center">
<p>ชื่องาน</p>
</div></th>
<th width="115" bgcolor="#FFFFCC"> <div align="center">
<p>วันที่รับงาน</p>
</div></th>
<th width="115" bgcolor="#FFFFCC"> <div align="center">
<p>วันที่คาดว่าเสร็จ</p>
</div></th>
<th width="99" bgcolor="#FFFFCC"> <div align="center">
<p>ประเภท</p>
</div></th>
<th width="130" bgcolor="#FFFFCC"> <div align="center">
<p>ชื่อผู้สั่ง</p>
</div></th>
<th width="130" bgcolor="#FFFFCC"><div align="center">
<p>ชื่อลูกค้า</p>
</div></th>
<th width="116" bgcolor="#FFFFCC"><div align="center">
<p>สถานะ</p>
</div></th>
<th width="40" bgcolor="#FFFFCC"><div align="center">
<p>แก้ไข</p>
</div></th>
<th width="40" bgcolor="#FFFFCC"><div align="center">
<p>ลบ</p>
</div></th>
</tr>
<?
$sql="SELECT * FROM working WHERE status='". $_GET['status']."'";
$dbquery = mysql_db_query($dbname, $sql);
while($result = mysql_fetch_array($dbquery)) { //** START ****/
?>
<tr>
<td><?=$result["id_work"];?></td>
<td><p>
<?=$result["name_job"];?>
</p></td>
<td><p>
<?=$result["start_job"];?>
</p></td>
<td><p>
<?=$result["expect_job"];?>
</p></td>
<td><p>
<?=$result["id_category"];?>
</p></td>
<td><p>
<?=$result["command"];?>
</p></td>
<td><p>
<?=$result["customer_name"];?>
</p></td>
<td><p>
<?=$result["status"];?>
</p></td>
<td align="center" valign="middle"><p><a href="event.php?id_work=<?php echo $result["id_work"];?>"></a><a href="event.php?id_work=<?php echo $result["id_work"];?>" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','img/edit1.png',1)"><img src="img/edit.png" width="28" height="28" id="Image2"></a><a href="event.php?id_work=<?php echo $result["id_work"];?>"></a></p></td>
<td align="center" valign="middle"><p><a href="delete_work.php?id_work=<?php echo $result["id_work"];?>" onClick="return CheckConfirm();"><img src="img/Detele.png" width="28" height="28" id="delete2"></a></p></td>
</tr>
<?
}
?>
</table>
</form>
<table width="900" border="0" align="" cellpadding="0" cellspacing="0">
<tr>
<td>. Total
<?= $Num_Rows;?>
Record :
<?=$Num_Pages;?>
Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
mysql_close($sql,$con);
?>
</td>
</tr>
</table>
<p><br>
</p></td>
</tr>
</table>
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2015-10-06 10:18:29 |
By :
Narybee |
View :
810 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมว่ากลับไปดู Code ดีกว่าครับ ยังมีการใช้ mysql ร่วมกับ mysqli สลับไปสลับมาครับ
|
|
|
|
|
Date :
2015-10-06 17:57:05 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|