รบกวนด้วยครับ searchออกมาได้ คือ หน้าแรก select ออกมาได้ครับ พอคลิกเข้าไปหน้าต่อไป Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\member\search.php on line 128 ครับ
Code (PHP)
<?
$page = $_GET['page'];
$num = 1;
$select_type="select * from member where $_POST[searchtype] LIKE '%$_POST[txtsearch]%' order by id asc";
$query_select=mysql_query($select_type);
$num_rows=mysql_num_rows($query_select);
if($num_rows<1){
echo "<br><br><center><font color=#666666 face=tahoma size=2>ไม่พบข้อมูลทีี่ท่านค้นหาค่ะ</font></center>";
}else{
$select="select * from member where $_POST[searchtype] LIKE '%$_POST[txtsearch]%' order by id asc";
$q_ry = mysql_query($select);
$num_rows=mysql_num_rows($q_ry);
$pagesize=10;
$rt=$num_rows%$pagesize;
if($rt!=0)
{
$totalpage=floor($num_rows/$pagesize)+1;
}
else
{
$totalpage=floor($num_rows/$pagesize);
$toppic_id=1;
}
if(empty($page))
{
$page=1;
}
mysql_free_result($q_ry);
$goto=($page-1)*$pagesize;
$sql_select_mem="Select * from (select *, right(day_ordain,4) y, substring(day_ordain,4,2) m, left(day_ordain,2) d from member ) tb order by y, m, d limit $goto,$pagesize";
$fect=mysql_query($sql_select_mem);
if(!$fect)
{
("ติดต่อฐานข้อมูลไม่ได้".mysql_error());
exit;
}
$bgcount=0;
while($rows=mysql_fetch_array($fect))
{
$status_name =$rows['status_name'];
$name_th =$rows['name_th'];
$n_name_th =$rows['n_name_th'];
$last_name_th =$rows['last_name_th'];
$rainy =$rows['rainy'];
$wantstudy_name =$rows['wantstudy_name'];
$room =$rows['room'];
$phone =$rows['phone'];
?>
<tbody>
<tr>
<td><? echo "$status_name "; ?></td>
<td><? echo "$name_th "; ?></td>
<td><? echo "$n_name_th"; ?></td>
<td><? echo "$last_name_th"; ?></td>
<td><? echo "$rainy"; ?></td>
<td><? echo "$wantstudy_name"; ?></td>
<td><? echo "$room"; ?></td>
<td><? echo "$phone"; ?></td>
<td><a href=detail.php?id=<? echo "$idmember"; ?>><span class="glyphicon glyphicon-pencil"></span></a></td>
<td><a href=edit.php?id=<? echo "$idmember"; ?>><span class="glyphicon glyphicon-pencil"></span></a></td>
<?
$num = $num+1;
}
echo "
</tbody>
</table>
<div align=center>
<ul class=\"pagination pagination-lg\"> ";
for($i=1;$i<$page;$i++)
{
echo"<li><a href='$PHP_SELF?page=$i'>$i</a></li>";
}
echo"<li class=\"active\"><a href=\"javascritp:;\">$page <span class=\"sr-only\">(current)</span></a></li> ";
for($i=$page+1;$i<=$totalpage;$i++)
{
echo"<li><a href='$PHP_SELF?page=$i'>$i</a></li>";
}
echo "</ul> </div>";
}
?>