|
|
|
ดึงข้อมูลมาแสดงแล้ว eror ครับ ... ช่วยด้วยครับพี่ เป็นหน้า ดีงข้อมูลจากดาต้าเบสมาแสดงครับ |
|
|
|
|
|
|
|
ช่วยด้วยครับพี่ เป็นหน้า ดีงข้อมูลจากดาต้าเบสมาแสดงครับ
Code (PHP)
<?php
//include("file:///C|/AppServ/www/Amsamui/scripts/ConnectDB.php");
include("scripts/ConnectDB.php");
$page=$_GET['page'];
$fromdate = $_GET['fromdate'];
$todate = $_GET['todate'];
$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
$email = $_GET['email'];
$order = $_GET['order'];
if (!$link)
echo "ERROR MYSQL";
else
{
mysql_select_db($DBName,$link);
$level='K.1';
//$query="SELECT * FROM tbst ";
//$query = "SELECT st_id,st_fname,st_lname,st_age FROM tbst WHERE st_level LIKE '%$firstname%'";
$query = "SELECT st_id,st_fname,st_lname,st_age FROM tbst WHERE st_level = '$level'";
/*
$query="SELECT booking_no, resrv_date, cust_first_name, cust_last_name, cust_email ";
$query .= " FROM reservation a INNER JOIN customer b ON a.cust_id = b.cust_id ";
$query .= " WHERE b.cust_first_name LIKE '%$firstname%' AND b.cust_last_name LIKE '%$lastname%' and b.cust_email like '%$email%'
";
*/
if($fromdate != "" && $todate =="")
{
$query .= " and a.resrv_date like '%$fromdate%' ";
}
if($fromdate == "" && $todate != "")
{
$query .= " and a.resrv_date like '%$todate%' ";
}
if($fromdate != "" && $todate != "")
{
$query .= " and a.resrv_date between '$fromdate' and '$todate'";
}
$result=mysql_query($query);
$totalrow = mysql_num_rows($result);
$pagesize = 10; // แสดงจำนวนข้อมูลในแต่ละหน้า
$totalpage = (int)($totalrow/$pagesize); // หาจำนวนหน้าทั้งหมด
// ถ้าจำนวนหน้าเป็นเศษให้ปัดขึ้นไป
if(($totalrow%$pagesize)!=0)
{
$totalpage += 1;
}
// หา record แรกที่จะแสดงของแต่ละหน้า
if(isset($page))
{
$pageno = $page;
$start = $pagesize*($pageno-1);
}else{
$pageno = 1;
$start = 0;
}
$query = "SELECT st_id,st_fname,st_lname,st_age FROM tbst WHERE st_level LIKE '%$firstname%'";
/*
$query="SELECT booking_no, resrv_date, cust_first_name, cust_last_name, cust_email ";
$query .= " FROM reservation a INNER JOIN customer b ON a.cust_id = b.cust_id ";
$query .= " WHERE b.cust_first_name LIKE '%$firstname%' AND b.cust_last_name LIKE '%$lastname%' and b.cust_email like '%$email%'
";
*/
if($fromdate != "" && $todate =="")
{
$query .= " and a.resrv_date like '%$fromdate%' ";
}
if($fromdate == "" && $todate != "")
{
$query .= " and a.resrv_date like '%$todate%' ";
}
if($fromdate != "" && $todate != "")
{
$query .= " and a.resrv_date between '$fromdate' and '$todate'";
}
$query .= " order by a.booking_no,a.resrv_date limit $start, $pagesize ";
$result=mysql_query($query)
?>
<form name="myform2">
<table border="1" cellspacing=0 celpadding=0 width="100%" bordercolor="#000000" style="border:thin; border-bottom-width:thin; border-bottom-style:solid; border-collapse:collapse; border-top:thick;">
<tr valign="top" bgcolor="#666666" style=" color:#FFFFFF" align="left"><td width="5%">Reserved ID</td> <td width="7%">Reserved Date</td> <td width="7%">Fisrt Name</td> <td width="7%">Last Name</a></td><td width="15%">Email</a></td><td width="4%">View</td> </tr>
<?php
/*while($row = mysql_fetch_row($result))
{*/
while($row = mysql_fetch_array($result))
{
print("<tr valign='top' bgcolor='#F8F8F8'>");
print("<td>$row[st_id]</td>");
print("<td>$row[st_fname]</td>");
print("<td>$row[st_lname]</td>");
print("<td>$row[st_nickname]</td>");
print("<td>$row[st_level]</td>");
print("<td align='center')'><a href='viewReserved.php?id=$row[st_id]'><img border='0px' src='image/icon_view.gif' ></a></td>");
print("</tr>");
}
/*
print("<tr valign='top' bgcolor='#F8F8F8'>");
print("<td>$row[0]</td>");
print("<td>$row[1]</td>");
print("<td>$row[2]</td>");
print("<td>$row[3]</td>");
print("<td>$row[4]</td>");
print("<td align='center')'><a href='viewReserved.php?id=$row[0]'><img border='0px' src='image/icon_view.gif' ></a></td>");
print("</tr>");*/
/*}*/
mysql_close( $link );
}
?>
</table>
<?php
if($pageno > 1)
{
echo "<a href=# onclick='getNews(",$pageno-1,")'><font color='#333333'>Previous</font></a> |";
}
for($i=1;$i<=$totalpage;$i++)
{
if($pageno==$i)
{
echo "<b>".$i."</b> |";
}else{
//echo "<a href='show.php?page=$i&ran=$rand'>$i</a> |";
echo "<a href=# onclick='getNews($i);'><font color='#333333'>$i</font></a> |";
}
}
if($pageno<$totalpage)
{
//echo " <a href='show.php?page=",$pageno+1,"&ran=$rand'>Next</a>";
echo " <a href=# onclick='getNews(",$pageno+1,")'><font color='#333333'>Next</font></a>";
}
?>
Tag : - - - -
|
|
|
|
|
|
Date :
2010-01-19 12:04:18 |
By :
เด็กสมุย |
View :
895 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$result=mysql_query($query);
echo $query;
ลองเอาค่าที่ได้ไปทดสอบบน Query ของ phpMyAdmin ครับ
|
|
|
|
|
Date :
2010-01-19 13:05:14 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|