|
|
|
ขอถามอะไรหน่อย ครับ ถ้า ผม ทำอย่างงี้ จะได่ไหม ครับ |
|
|
|
|
|
|
|
ทำได้ครับ เอา $user_id ไปใช้ได้เลย
|
|
|
|
|
Date :
2011-04-20 13:15:47 |
By :
avsqlz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ครับ เท่ากับ ได้ครับ
|
|
|
|
|
Date :
2011-04-20 13:17:46 |
By :
compeng |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แต่ค่า $read_date['id']; มันมาจาก array น่ะครับ เออ ขอ ดู ตัวอย่างหน่อยได้ไหม
|
ประวัติการแก้ไข 2011-04-20 13:39:52
|
|
|
|
Date :
2011-04-20 13:33:04 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ก็กำหนด
$user_id = $read_date['id'];
ไว้ในลูป ครับ
EX
Code (PHP)
<?php
$sql = "SELECT id,name,surname FROM member";
$result = mysql_query( $sql, $connect);
while($fd = mysql_fetch_array($result)) {
$id = $fd['id'];
$name = $fd['name'];
$surname = $fd['surname'];
} //end while
?>
|
|
|
|
|
Date :
2011-04-20 13:50:28 |
By :
avsqlz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
งง ครับเพราะ ผม ใช้ไปแล้ว อ่ะ ครับ fech array อ่ะ ครับ
ลอง ดู โค๊ด ผม ก่อน ล่ะกัน ครับ
Code (PHP)
<?
include "./include/connect1.php";
?>
<body>
<form name="form1" method="post" action="">
<br>
<table width="349" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td width="345"><table width="100%" border="0" cellpadding="1" cellspacing="1">
<tr class="header24">
<td colspan="2" bgcolor="#F0F0F0"><div align="center" class="title2">
<h3>Select Name</h3>
</div></td>
</tr>
<tr class="header24">
<td colspan="2"> </td>
</tr>
<tr class="font18">
<td class="font18" align="right">Select Byname: </td>
<td class="font14-5"><span class="font14">
<select name="dte1" class="font18" id="dte1">
<option value="all" selected>Select</option>
<?
// ทำการ select ค่าของวันที่มีในฐานข้อมูลมาเพื่อแสดง แล้วให้ผู้ใช้เลือก
$date= $read_data['fname'];
$sql_option = "SELECT DISTINCT `fname` FROM `user_table` group by fname ";
$result_option = mysql_query($sql_option);
while($read_option = mysql_fetch_array($result_option)){
?>
<option value="<?=$read_option['fname']?>">
<?=$read_option['fname']?>
</option>
<? } ?>
</select>
</span></td>
</tr>
<tr class="font18">
<td class="font18"> </td>
<td class="font14-5"> </td>
</tr>
<tr>
<td width="36%" class="font14-5"> </td>
<td width="64%" class="font14-5"><input name="Submit" type="submit" class="font14" value="Search" /></td>
</tr>
</table></td>
</tr>
</table>
<p> </p>
<table width="791" height="44" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr class="font22">
<td width="769" valign="top"><table width="877" border="1" align="center" cellpadding="0" cellspacing="1">
<tr class="header24">
<td colspan="11" bgcolor="#F0F0F0"><div align="center" class="header">
<h3>DataDetail</h3>
</div></td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#CCCCCC" class="font22">
<td width="88" align="center" class="font14-5"><div align="center">User_id</div></td>
<td width="145" align="center" class="font14-5"><div align="center">name</div></td>
<td width="200" align="center" class="font14-5"><div align="center">lname</div></td>
<td width="396" align="center" class="font14-5"><div align="center">position</div></td>
</tr>
<?
$dte1 = $_REQUEST['dte1'];
// $dte2 = $_REQUEST['dte2'];
$start = $dte1;
// $end = $dte2;
$sql_seleect = "SELECT * FROM user_table where fname = '$dte1' ";
$result_select = mysql_query($sql_seleect) or die(mysql_error());
while($read_data = mysql_fetch_array($result_select)){
?>
<tr class="font18">
<td align="left" valign="top" class="font14-0"><div align="center">
<div align="center">
<div align="center">
<div align="center"><? echo $read_data['user_id']; ?></div>
</div>
</div>
</div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['fname']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['lname']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="left"><? echo $read_data['position']; ?></div><div align="left"></div></td>
</tr>
<? } ?>
</table></td>
</tr>
</table>
<p> </p>
<table width="754" height="44" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr class="font22">
<td width="723" valign="top"><table width="1903" height="162" border="1" align="center" cellpadding="0" cellspacing="1">
<tr class="header24">
<td colspan="12" align="center" bgcolor="#F0F0F0"><div align="center" class="header">
<h3>Data Time Sheet</h3>
</div></td>
</tr>
<tr class="header24">
<td width="72" rowspan="2" align="center" bgcolor="#F0F0F0"><div align="center">no</div></td>
<td width="116" rowspan="2" bgcolor="#F0F0F0"><div align="center">Day</div></td>
<td width="187" rowspan="2" bgcolor="#F0F0F0"><div align="center">Nomalwork date </div> <div align="center"></div></td>
<td height="41" colspan="2" align="center" bgcolor="#F0F0F0">Normal Work</td>
<td width="243" rowspan="2" align="center" bgcolor="#F0F0F0"><p>Shift date (Date_in)</p></td>
<td width="116" rowspan="2" align="center" bgcolor="#F0F0F0">Time_in</td>
<td width="180" rowspan="2" align="center" bgcolor="#F0F0F0">Shift date (Date_out)</td>
<td width="124" rowspan="2" align="center" bgcolor="#F0F0F0">Time_out</td>
<td width="507" rowspan="2" align="center" bgcolor="#F0F0F0">Detail</td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="" class="font22">
<td width="178" align="center" bgcolor="#F0F0F0" class="font14-5">Timein</td>
<td width="147" align="center" bgcolor="#F0F0F0" class="font14-5">Timeout</td>
</tr>
<?
$dte1 = $_REQUEST['dte1'];
// $dte2 = $_REQUEST['dte2'];
$start = $dte1;
// $end = $dte2;
$sql_seleect = "SELECT *,
DATE_FORMAT(n_timein,'%H:%i') as ntimein,
DATE_FORMAT(n_timeout,'%H:%i')as ntimeout,
DATE_FORMAT(n_timein,'%Y-%m-%d') As n_date,
DATE_FORMAT(s_timein,'%Y-%m-%d') As s_date_timein,
DATE_FORMAT(s_timeout,'%Y-%m-%d') As s_date_out,
DATE_FORMAT(s_timein,'%H:%i') as stimein,
DATE_FORMAT(s_timeout,'%H:%i') as stimeout
FROM time_sheet_table,user_table
WHERE user_table.user_id = time_sheet_table.user_id and fname = '$start' ";
$result_select = mysql_query($sql_seleect) or die(mysql_error());
while($read_data = mysql_fetch_array($result_select)){
?>
<tr class="font18">
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['id']; ?></div>
<div align="center"></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['day']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['n_date'];?></div> <div align="right"></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['ntimein'];?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['ntimeout'] ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['s_date_timein'];?></div><div align="right"></div> <div align="right"></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['stimein'];?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['s_date_out'];?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['stimeout'];?></div></td>
<td align="left" valign="top" class="font14-0"><? echo $read_data['detail'];?></td>
</tr>
<? $userid = $read_date['day'] ;
echo $userid ;
?>
<? } ?>
</table></td>
</tr>
</table>
<p><? echo $userid ; ?></p>
<p></p>
</form>
<p align="center"><a href="main.php"><strong>กลับหน้าหลัก</strong></a></p>
</body>
|
|
|
|
|
Date :
2011-04-20 14:28:33 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พางงไปด้วยเลยงับ
|
|
|
|
|
Date :
2011-04-20 14:50:52 |
By :
badkung04 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$sql_seleect = "SELECT *,
DATE_FORMAT(n_timein,'%H:%i') as ntimein,
DATE_FORMAT(n_timeout,'%H:%i')as ntimeout,
DATE_FORMAT(n_timein,'%Y-%m-%d') As n_date,
DATE_FORMAT(s_timein,'%Y-%m-%d') As s_date_timein,
DATE_FORMAT(s_timeout,'%Y-%m-%d') As s_date_out,
DATE_FORMAT(s_timein,'%H:%i') as stimein,
DATE_FORMAT(s_timeout,'%H:%i') as stimeout
FROM time_sheet_table,user_table
WHERE user_table.user_id = time_sheet_table.user_id and fname = '$start' ";
$result_select = mysql_query($sql_seleect) or die(mysql_error());
while($read_data = mysql_fetch_array($result_select)){
?>
<tr class="font18">
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['id']; ?></div>
<div align="center"></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['day']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['n_date'];?></div> <div align="right"></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['ntimein'];?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['ntimeout'] ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['s_date_timein'];?></div><div align="right"></div> <div align="right"></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['stimein'];?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['s_date_out'];?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['stimeout'];?></div></td>
<td align="left" valign="top" class="font14-0"><? echo $read_data['detail'];?></td>
</tr>
<? $userid = $read_date['day'] ; // <================ ก็ประกาศได้แล้วนิ
echo $userid ; // <================ ก็ประกาศได้แล้วน
?>
<? } ?>
|
|
|
|
|
Date :
2011-04-20 16:52:12 |
By :
avsqlz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังไม่ได้ เลย อ่ะ ครับ งง แปลก จัง
|
|
|
|
|
Date :
2011-04-21 11:11:51 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มัน error ว่าอะไรครับ
แล้วจะไปประกาศตัวแปรตรงไหนครับ
จะได้ช่วยแก้ให้ถูกได้
|
|
|
|
|
Date :
2011-04-21 11:35:26 |
By :
avsqlz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่ได้ยังไง เขียนอะไรลงไป ช่วยบอกด้วยครับ
เพราะบอกแค่ไม่ได้นี่ สาเหตุมีเป็นแสน
|
|
|
|
|
Date :
2011-04-21 11:39:34 |
By :
PlaKriM |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
result_select = mysql_query($sql_seleect) or die(mysql_error());
while($read_data = mysql_fetch_array($result_select)){
?>
<tr class="font18">
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['id']; ?></div>
<div align="center"></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['day']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['n_date'];?></div> <div align="right"></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['ntimein'];?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['ntimeout'] ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['s_date_timein'];?></div><div align="right"></div> <div align="right"></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['stimein'];?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['s_date_out'];?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['stimeout'];?></div></td>
<td align="left" valign="top" class="font14-0"><? echo $read_data['detail'];?></td>
</tr>
<? $userid = $read_date['day'] ; // <================ ก็ประกาศได้แล้วนิ // ไอ้ตรงนี้ อ่ะ มัน ประกาศนอก ลูปไม่ได้ อยู่ แล้ว ใช่ไหม ครับ
echo $userid ; // <================ ก็ประกาศได้แล้วน
?>
<? } ?>
|
ประวัติการแก้ไข 2011-04-21 11:58:57
|
|
|
|
Date :
2011-04-21 11:58:06 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$read_data กับ $read_date
|
|
|
|
|
Date :
2011-04-21 12:03:16 |
By :
PlaKriM |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|