|
|
|
รบกวนแก้สคริปให้มันแบ่งหน้าให้หน่อยครับ ตอนนี้อืดมากมีรายการมากกว่า 300 เรคคอร์ด |
|
|
|
|
|
|
|
พอดีอยากจะทำให้มันแบ่งหน้าเป็นหลายๆหน้า หน้าละ 20 รายการ
เพราะตอนนี้อืดมากเวลาเปิดหน้านี้ มีมากกว่า 300 รายการ
บกวนผู้รู้ช่วยหน่อยครับ
Code (PHP)
<?php
session_start();
include('connect.php');
if($_SESSION["UserName"] == "")
{
echo "???!";
exit();
}
$ss1 = "select * from $tb_member where $fiw_user ='$_SESSION[UserName]'";
$qq1 = odbc_exec($connect,$ss1);
$aa1 = odbc_fetch_array($qq1);
?>
<!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" />
<title>ตลาดนัดคลองถม</title>
<style type="text/css">
<!--
A { color: #0000FF; text-decoration: none; }
.style10 {color: #33CC00}
.style12 {
color: #2A00FF;
font-weight: bold;
}
.style14 {
color: #0000FF;
font-size: 18px;
font-weight: bold;
}
.style15 {
color: #FF0000;
font-weight: bold;
}
.style16 {color: #FF9900}
-->
body {
background-color: #FFFFFF;
}
body {
background-image: url(..);
background-repeat: repeat-x;
background-attachment: fixed;
background-position: top center;
background-color: #FFFFCC;
}
.style17 {
color: #FF0055
}
.style18 {
color: #007F55;
font-weight: bold;
}
.style19 {color: #770000}
.style22 {
color: #55DFFF
}
.style24 {
color: #FC0
}
body p {
font-weight: bold;
}
.style30 {
color: #2A3FFF;
}
</style>
<script type='text/javascript'>
/***********************************************
* Disable Text Selection script- ? Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
function disableSelection(target){
if(typeof target.onselectstart != 'undefined') //IE route
target.onselectstart=function(){ return false; }
else if(typeof target.style.MozUserSelect != 'undefined') //Firefox route
target.style.MozUserSelect = 'none'
else //All other route (ie: Opera)
target.onmousedown = function(){ return false; }
target.style.cursor = 'default';
}
/* Disable Right Click */
var message="You may not right mouse click this page.";
if (navigator.appName == 'Microsoft Internet Explorer'){
function NOclickIE(e) {
if (event.button == 2 || event.button == 3) {
alert(message);
return false;
}
return true;
}
document.onmousedown=NOclickIE;
document.onmouseup=NOclickIE;
window.onmousedown=NOclickIE;
window.onmouseup=NOclickIE;
}
else {
function NOclickNN(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}}}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=NOclickNN; }
document.oncontextmenu=new Function("alert(message);return false")
}
function disableCtrlKeyCombination(e){
//list all CTRL + key combinations you want to disable
var forbiddenKeys = new Array('a', 'c', 's', 'u', 'x');
var key;
var isCtrl;
if(window.event){
key = window.event.keyCode; //IE
if(window.event.ctrlKey) isCtrl = true;
else isCtrl = false;
}
else{
key = e.which; //firefox
if(e.ctrlKey) isCtrl = true;
else isCtrl = false;
}
//if ctrl is pressed check if other key is in forbidenKeys array
if(isCtrl){
for(i=0; i<forbiddenKeys .length; i++){
//case-insensitive comparation
if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase()){
alert('Key combination CTRL + '+String.fromCharCode(key)+' has been disabled.');
return false;
}
}
}
return true;
}</script>
<script type="text/javascript" src="/a/script/textsizer.js">
/***********************************************
* Document Text Sizer- Copyright 2003 - Taewook Kang. All rights reserved.
* Coded by: Taewook Kang (http://www.txkang.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
</head>
<body>
<table width="1050" border="2" align="center" cellpadding="1" cellspacing="0">
<h2 align="center"><span class="style30">ตลาดนัดคลองถม</span></h2>
<p align="center"><span class="style18">ใช้สำหรับซื้อ-ขายไอเท็มต่างๆ</p>
<div><p align="center"><span class="style18"> <b>คำเตือน : </b>กรุณาออกจากเกมก่อนทุกครั้ง</p></div>
<div><p align="center"><span class="style18"> <b>คุกกี้ในธนาคาร : </b><?php echo $aa1["Money2"]; ?></p></div>
<div class="entry">
<div class="sep"></div>
</div>
<tbody><tr>
<th width="50" align="center" ><div align="center" class="style12">No.</div></th>
<th width="156" align="center" ><div align="center" class="style12">ชื่อไอเท็ม</div></th>
<th width="115" align="center" ><div align="center">ผู้ขาย</div></th>
<th width="59" align="center" scope="col"><div align="center">ตีบวก</div></th>
<th width="80" align="center" scope="col"><div align="center">ทำลาย/เกราะ </div></th>
<th width="80" align="center" scope="col"><div align="center"><span class="style15">ATK</span> </div></th>
<th width="80" align="center" scope="col"><div align="center"><span class="style22">DEF</span> </div></th>
<th width="80" align="center" scope="col"><div align="center"><span class="style10">DEX</span> </div></th>
<th width="80" align="center" scope="col"><div align="center"><span class="style24">LUK</span> </div></th>
<th width="64" align="center" scope="col"><div align="center">สถานะ </div></th>
<th width="52" align="center" scope="col"><div align="center">จำนวน</div></th>
<th width="95" align="center" scope="col"><div align="center">ราคา / คุกกี้</div></th>
</tr>
<?php
$s1 = "select * from KongTom where Stat = 1 ORDER BY TemplateID ASC,Price DESC";
$q1 = odbc_exec($connect,$s1);
while ($a1=odbc_fetch_array($q1)) {
$sql = "select * from Sys_Users_Goods where ItemID = '$a1[ItemID]'";
$query = odbc_exec($connect,$sql);
while ($row=odbc_fetch_array($query)) {
$sql2 = "select * from Shop_Goods where TemplateID='$row[TemplateID]'";
$query2 = odbc_exec($connect,$sql2);
$row2 = odbc_fetch_array($query2);
switch ($row[IsGold]) {
case "0" : $stat = '<span class="style10">ธรรมดา</span>';break;
case "1" : $stat = '<span class="style16">หล่อทอง</span>';break;
}
?>
<tr>
<td align="center" ><?php echo $a1["ID"];?></td>
<td align="center" class="style12"><?php echo $row2["Name"];?></td>
<td align="center" class="style18"><?php echo $a1["NickName"];?></td>
<td align="center" class="align-center">+ <?php echo $row["StrengthenLevel"];?></td>
<td align="center" class="style14"><?php echo $row2["Property7"];?></td>
<td align="center" class="align-center"><?php echo $row2["Attack"];?> <span class="style15">(<?php echo $row["AttackCompose"];?>)</span></td>
<td align="center" class="align-center"><?php echo $row2["Defence"];?><span class="style22"> (<?php echo $row["DefendCompose"];?>)</span></td>
<td align="center" class="align-center"><?php echo $row2["Agility"];?><span class="style10"> (<?php echo $row["AgilityCompose"];?>)</span></td>
<td align="center" class="align-center"><?php echo $row2["Luck"];?><span class="style24"> (<?php echo $row["LuckCompose"];?>)</span></td>
<td align="center" class="align-center"><?php echo $stat ;?></td>
<td align="center" class="align-center"><span class="style17"><?php echo $row["Count"];?></span></td>
<td align="center" class="align-center"><span class="style14"><?php echo $a1["Price"];?></span></td>
<form id="form2" name="form2" method="post" onsubmit="return confirm('ยืนยันไอเท็มที่จะขาย [<?php echo $row2["Name"];?>] จำนวน <?php echo $row["Count"];?> ชิ้น ราคา <?php echo $a1["Price"];?> คุกกี้');" action="pay_item.php">
<td width="38" class="align-center">
<input name="button3" type="submit" onclick="Conf" id="Change" value="ชื้อ" /></td>
<input type="hidden" name="id1" id="id1" value="<?php echo $row["ItemID"]; ?>"/>
<input type="hidden" name="user1" id="user1" value="<?php echo $aa1["UserID"]; ?>"/>
<input type="hidden" name="coo" id="coo" value="<?php echo $a1["Price"]; ?>"/>
</form>
</tr>
<?php }
}
?>
</tbody>
</table>
<div class="entry">
<div class="sep"></div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</table>
<td><label>
<div align="center">
<br />
<a href="logout.php"><img src="img/logoff.png" width="120" height="33" border="0" /></a></div>
</label></td>
</tr>
</div>
</body>
</html>
Tag : PHP, Ms SQL Server 2012, JavaScript
|
|
|
|
|
|
Date :
2015-03-05 18:18:33 |
By :
ballnetza |
View :
1004 |
Reply :
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สคริปต์แบ่งหน้ามีเยอะแยะเลยครับ ที่ผมเอาลิ้งค์มาแปะนี่ก็ใช้ได้ ลองเปิดดูวิธีเขียน เพิ่มเติมในโค้ด
ตย.สั้นๆ
Code (PHP)
require_once '../Okvee/Pagination/Pagination.php';
use Okvee\Pagination\Pagination;
$config['base_url'] = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$config['per_page'] = $limit; // limit display per page.
$config['total_rows'] = count($data);
$pagination = new Pagination($config);
echo $pagination->createLinks();
ที่เหลือก็แค่เอาค่า querystring pagination มาใช้กับ limit, offset ใน mysql query นะครับลองดูบทความสอนในเว็บ Thaicreate ก็มีเพียบ ไม่ได้ตรงไหนค่อยมาว่ากัน
|
|
|
|
|
Date :
2015-03-05 22:11:23 |
By :
mr.v |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังทำไมได้เลย
|
|
|
|
|
Date :
2015-03-08 12:32:02 |
By :
ballnetza |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ ODBC ทำแบบประมาณนี้ก็ได้ครับ ไม่ต้อง ทำจาก sql
Code (PHP)
$page=$_GET[page];
$perpage=30;
$page=(trim($page)=='')?1:$page;
$numrows = odbc_num_rows($result);
$numpage=ceil($numrows/$perpage);
$st=(($page-1)*$perpage)+1;
$en=$page*$perpage;
$en=($en>$numrows)?$numrows:$en;
for($i=$st;$i<=$en;$i++){
print_r(odbc_fetch_array($result,$i));
}
for($i=1;$i<$numpage;$i++){
if($page==$i){
echo"<b>$i</b> ";
}
else{
echo"<a href='".$_SERVER[PHP_SELF]."?page=$i' >$i</a> ";
}
}
ปล .ลองดูก่อนนะครับผมไม่แน่ใจว่ารองรับ php ทุก version หรือเปล่า
|
|
|
|
|
Date :
2015-03-08 17:41:09 |
By :
ผ่านมา |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|