|
 |
|
ช่วยดู Code แล้วใส่ที่ให้เลือกหน้าให้หน่อยคับ คือ Code ผม เวลารันแล้ว จะเป็นการให้เลือก ประเภท แล้วจะแสดงรูปตามที่เราเลือกประเภทนั้น |
|
 |
|
|
 |
 |
|
คือ ผมลองแก้ตามที่บอกแล้ว คับ ก็ยังไม่ได้ คับ
โดยพอผมรันเว็บจะเป็นดังนี้
http://upload.tarad.com/viewer.php?id=5373338404767f1f1de7f5480fb57ecf.JPG
แล้วพอผมเลือกประเภทเป็น sss จะเป็นดังนี้
http://upload.tarad.com/viewer.php?id=1eb4b9cac0dff46822f7d6acbff3677b.JPG
แล้วพอผมคลิกเลือกหน้าที่2 ก็เป็นแบบนี้
http://upload.tarad.com/viewer.php?id=daa1c20a4141a3aa52241dea9d6b1e4d.JPG
พอ เราคลิกเลือกหน้าที่2 มันเหมือนกลับไปยังหน้าแรกสุดไหม่เลย คับ พอมีวิธีแก้ให้มันแสดงข้อมูลหน้าที่2 ไหม คับ ช่วยแนะนำทีคับบบ ขอบคุณคับบบบ
นี้ Code ทั้งหมดประะมาณนี้ คับบบบ
Code (PHP)
<!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>Untitled Document</title>
<style type="text/css">
<!--
<body onload='window.open("Sample.htm",null,"height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");'>
background-color: #CCCCCC;
}
-->
</style></head>
<body>
<table width="97%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td bgcolor="#CCCCCC"><div align="center">
<table width="73%" height="267" border="0" cellpadding="2" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<td height="74"><img src="image/Graphic3.png" width="300" height="70" /></td>
</tr>
<tr bgcolor="#CCCCCC">
<td height="26" bgcolor="#CC99CC"><strong> <img src="image/icon_home.png" width="16" height="16" /> <a href="index.php">หน้าหลัก</a> <img src="image/icon_blueflower.gif" width="10" height="10" /> <a href="add_mode.php">เพิ่มประเภทรูป</a> <img src="image/icon_brands.png" width="16" height="16" /> <a href="add_picture.php">เพิ่มรูป</a> <img src="image/Admin.gif" width="16" height="16" /> <a href="contact_me.php">ติดต่อเรา</a></strong></td>
</tr>
<tr bgcolor="#CCCCCC">
<td height="166" bgcolor="#FFFFFF"><div align="center">
</div>
<form action="" method="post">
<div align="center">
<?
$mode_now=$_POST['mode'];
$mode1=$_POST['mode1'];
//echo "$mode_now";
?>
<p>
<select name="mode" onchange="javascript:this.form.submit()";>
<?
echo "<option value=null $select>เลือกประเภทรูป </option>";
include "conn.php";
$result=mysql_query('SELECT * FROM mode ');
while($rs=mysql_fetch_array($result)){
if($mode_now==$rs[id_m]){$select="selected";}else{$select="";}
//if($mode1==$rs[id_m]){$select="selected";}else{$select="";}
echo "<option value=$rs[id_m] $select>$rs[name_mode] </option>";
}
?>
</select>
</p>
<p><?
include "conn.php";
if(!isset($start)){
$start = 0;
}
$limit = '2';
$objDB = mysql_select_db("pic");
$strSQL = "SELECT * FROM data ";
if(!empty($mode_now)){
$strSQL .= " where id_m = $mode_now LIMIT $start,$limit ";
}
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
echo "<td>";
?>
</div>
<div align="center">
<table width="120" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100"><div align="center"><a href="image/<?=$objResult["name_pic"];?>" target="_blank"><img src="image/<?=$objResult["name_pic"];?>" width="100" height="100" border="0"></a></div></td>
<td width="20"><div align="center" ><? echo $objResult["name_pic"];?> </a></div></td>
</tr>
</table>
<?
echo"</td>";
if(($intRows)%4==0)
{
echo"</tr>";
}
else
{
echo "<td>";
}
}
echo"</tr></table>";
?>
<?
$Qtotal = mysql_query("select * from data where id_m = '$mode_now'"); /*คิวรี่หาจวนแถวทั้งหมด*/
$total = mysql_num_rows($Qtotal); // หาจำนวน record
//echo "มีหัวข้อทั้งหมด $total หัวข้อ";
//echo "แสดงหน้าละ $limit หัวข้อ<br />";
echo "<hr />";
/* ตัวแบ่งหน้า */
$page = ceil($total/$limit); // เอา record ทั้งหมด หารด้วย จำนวนที่จะแสดงของแต่ละหน้า
//echo "[<a href='index.php?file=view_login'>All</a>]";
/* เอาผลหาร มาวน เป็นตัวเลข เรียงกัน เช่น สมมุติว่าหารได้ 3 เอามาวลก็จะได้ 1 2 3 */
for($i=1;$i<=$page;$i++){
if($_GET['page']==$i){ //ถ้าตัวแปล page ตรง กับ เลขที่วนได้
echo "[<a href='index.php?file=view_login&start=".$limit*($i-1)."&page=$i'><B>$i</B></A>]"; //ลิ้งค์ แบ่งหน้า เงื่อนไขที่ 1
}else{
echo "[<a href='index.php?file=view_login&start=".$limit*($i-1)."&page=$i'>$i</A>]"; //ลิ้งค์ แบ่งหน้า เงื่อนไขที่ 2
}
}
//mysql_close($objConnect);
?> </p>
</div>
</form></p>
<p> </p></td>
</tr>
</table>
</div></td>
</tr>
</table>
</body>
</html>
ช่วยดูให้ที คับบ ติดมานานมากๆๆ ไม่รู้จะทำไง คับบบบ ขอบคุณคับบบบบบบบ
|
 |
 |
 |
 |
Date :
2009-11-29 18:21:11 |
By :
hero_big |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มี ใครช่วยหน่อย เลยหลอ คับบบบบ
ติดตรงนี้ ตั้งนาน ไม่รู้ทำไง แล้ว คับ ช่วยหน่อย คับบบบบ
ไม่รู้ผิดตรงไหน คับบบบบ
ขอบคุณคับบบบบบบ
|
 |
 |
 |
 |
Date :
2009-11-29 20:07:26 |
By :
hero_big |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้ให้แล้วครับแต่ไม่รู้ใช้ได้ยังลองดูครับ
<!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>Untitled Document</title>
<style type="text/css">
<!--
<body onload='window.open("Sample.htm",null,"height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");'>
background-color: #CCCCCC;
}
-->
</style></head>
<body>
<table width="97%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td bgcolor="#CCCCCC"><div align="center">
<table width="73%" height="267" border="0" cellpadding="2" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<td height="74"><img src="image/Graphic3.png" width="300" height="70" /></td>
</tr>
<tr bgcolor="#CCCCCC">
<td height="26" bgcolor="#CC99CC"><strong> <img src="image/icon_home.png" width="16" height="16" /> <a href="index.php">หน้าหลัก</a> <img src="image/icon_blueflower.gif" width="10" height="10" /> <a href="add_mode.php">เพิ่มประเภทรูป</a> <img src="image/icon_brands.png" width="16" height="16" /> <a href="add_picture.php">เพิ่มรูป</a> <img src="image/Admin.gif" width="16" height="16" /> <a href="contact_me.php">ติดต่อเรา</a></strong></td>
</tr>
<tr bgcolor="#CCCCCC">
<td height="166" bgcolor="#FFFFFF"><div align="center">
</div>
<form action="" method="get">
<div align="center">
<?
$mode_now=$_GET['mode'];
//$mode1=$_POST['mode1'];
//echo "$mode_now";
?>
<p>
<select name="mode" onchange="javascript:this.form.submit()";>
<?
echo "<option value=null $select>เลือกประเภทรูป </option>";
include "conn.php";
$result=mysql_query('SELECT * FROM mode ');
while($rs=mysql_fetch_array($result)){
if($mode_now==$rs[id_m]){$select="selected";}else{$select="";}
//if($mode1==$rs[id_m]){$select="selected";}else{$select="";}
echo "<option value=$rs[id_m] $select>$rs[name_mode] </option>";
}
?>
</select>
</p>
<p><?
include "conn.php";
if(!isset($start)){
$start = 0;
}
$start = (int)$start;
$limit = '2';
$objDB = mysql_select_db("pic");
$strSQL = "SELECT * FROM data ";
if(!empty($mode_now)){
$strSQL .= " where id_m = '$mode_now' LIMIT $start,$limit ";
}
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
echo "<td>";
?>
</div>
<div align="center">
<table width="120" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100"><div align="center"><a href="image/<?=$objResult["name_pic"];?>" target="_blank"><img src="image/<?=$objResult["name_pic"];?>" width="100" height="100" border="0"></a></div></td>
<td width="20"><div align="center" ><? echo $objResult["name_pic"];?> </a></div></td>
</tr>
</table>
<?
echo"</td>";
if(($intRows)%4==0)
{
echo"</tr>";
}
else
{
echo "<td>";
}
}
echo"</tr></table>";
?>
<?
$Qtotal = mysql_query("select * from data where id_m = '$mode_now'"); /*คิวรี่หาจวนแถวทั้งหมด*/
$total = mysql_num_rows($Qtotal); // หาจำนวน record
//echo "มีหัวข้อทั้งหมด $total หัวข้อ";
//echo "แสดงหน้าละ $limit หัวข้อ<br />";
echo "<hr />";
/* ตัวแบ่งหน้า */
$page = ceil($total/$limit); // เอา record ทั้งหมด หารด้วย จำนวนที่จะแสดงของแต่ละหน้า
//echo "[<a href='index.php?file=view_login'>All</a>]";
/* เอาผลหาร มาวน เป็นตัวเลข เรียงกัน เช่น สมมุติว่าหารได้ 3 เอามาวลก็จะได้ 1 2 3 */
for($i=1;$i<=$page;$i++){
if($_GET['page']==$i){ //ถ้าตัวแปล page ตรง กับ เลขที่วนได้
echo "[<a href='index.php?file=view_login&start=".$limit*($i-1)."&page=$i&mode=$mode_now'><B>$i</B></A>]"; //ลิ้งค์ แบ่งหน้า เงื่อนไขที่ 1
}else{
echo "[<a href='index.php?file=view_login&start=".$limit*($i-1)."&page=$i&mode=$mode_now'>$i</A>]"; //ลิ้งค์ แบ่งหน้า เงื่อนไขที่ 2
}
}
//mysql_close($objConnect);
?> </p>
</div>
</form></p>
<p> </p></td>
</tr>
</table>
</div></td>
</tr>
</table>
</body>
</html>
|
 |
 |
 |
 |
Date :
2009-11-29 23:04:22 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้ว คับบบ แก้ตามคุณ num ได้เลย คับบบบบบบบบบบ
ขอบคุณ คุณ num มากๆๆๆๆๆๆๆๆๆ คับ
คิดว่าจะไม่ได้ แล้วววววว
ขอบคุณมากๆๆ นะคับบบบบบบบบบบบ
  
รบกวนถามอีกนิด ผมพลาดตรงไหน คับ
แต่อย่างไง ก็ขอบคุณมากๆๆๆๆๆๆๆๆๆๆๆๆๆๆ คับบบบบบบบ
|
 |
 |
 |
 |
Date :
2009-11-29 23:21:06 |
By :
hero_big |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตรง form search กำหนดเป็น method="get" จะสะดวกกว่าครับ
<form method="get">
$mode_now=$_GET['mode'];
เพราะเราสามารถ ส่งตัวแปร mode ไปกับ url เวลากดปุ่มเปลี่ยนหน้าได้ครับ
echo "[<a href='index.php?file=view_login&start=".$limit*($i-1)."&page=$i&mode=$mode_now'><B>$i</B></A>]"
|
 |
 |
 |
 |
Date :
2009-11-29 23:26:40 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|