|
|
|
แทรกโค๊ดแบ่งหน้าแล้วขึ้น error แบบนี้คับ...Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result |
|
|
|
|
|
|
|
โค๊ดปกติที่ไม่แบ่งหน้า และไม่ขึ้น error
Code (PHP)
<form>
<table width="490" height="25" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bordercolorlight="#999999" bordercolordark="#FFFFFF">
<tr class="title_table">
<td width="36">ลำดับ</td>
<td width="155">ชื่อ </td>
<td width="155">วันที่ / เวลา </td>
<td width="80">คอร์ส</td>
<td width="49">ห้อง</td>
</tr>
<?
$sql2="select member_id from member where user_id='$user_id' ";
$dbquery2=mysql_db_query($dbname, $sql2);
$result=mysql_fetch_array($dbquery2);
$member_id=$result[0];
if($course)
{
$sql="SELECT member.name, selectcourse.course_date, selectcourse.coursename, selectcourse.place
FROM
`coursedata`
Inner Join `selectcourse` ON `coursedata`.`course_id` = `selectcourse`.`course_id`
Inner Join `member` ON `coursedata`.`member_id` = `member`.`member_id`
where selectcourse.coursename LIKE '$course'
and selectcourse.course_date BETWEEN '$start_date' AND '$to_date'
ORDER BY course_date";
}
else
{
$sql="SELECT member.name, selectcourse.course_date, selectcourse.coursename, selectcourse.place
FROM
`coursedata`
Inner Join `selectcourse` ON `coursedata`.`course_id` = `selectcourse`.`course_id`
Inner Join `member` ON `coursedata`.`member_id` = `member`.`member_id`
order by course_date ";
}
//echo $sql;
$dbquery = mysql_query($sql);
$order=1;
while($result=mysql_fetch_array($dbquery))
{
$date = $result[course_date];
list($year, $month, $day) = split('[/.-]', $date);
$date = "$day-$month-$year";
//echo $date;
echo"<tr>
<td align='center'>$order</td>
<td>$result[name]</td>
<td align='center'>$date</td>
<td> $result[coursename]</td>
<td align='center'>$result[place]</td>";
?>
</tr>
<?
$order++;
}
?>
</table>
</form>
เมื่่อแทรกโค๊ดแบ่งหน้ามันจะขึ้น error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\fitness\count_course.php on line 247
<form>
<table width="490" height="25" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bordercolorlight="#999999" bordercolordark="#FFFFFF">
<tr class="title_table">
<td width="36">ลำดับ</td>
<td width="155">ชื่อ </td>
<td width="155">วันที่ / เวลา </td>
<td width="80">คอร์ส</td>
<td width="49">ห้อง</td>
</tr>
<?
$sql2="select member_id from member where user_id='$user_id' ";
$dbquery2=mysql_db_query($dbname, $sql2);
$result=mysql_fetch_array($dbquery2);
$member_id=$result[0];
if($course)
{
$sql="SELECT member.name, selectcourse.course_date, selectcourse.coursename, selectcourse.place
FROM
`coursedata`
Inner Join `selectcourse` ON `coursedata`.`course_id` = `selectcourse`.`course_id`
Inner Join `member` ON `coursedata`.`member_id` = `member`.`member_id`
where selectcourse.coursename LIKE '$course'
and selectcourse.course_date BETWEEN '$start_date' AND '$to_date'
ORDER BY course_date";
}
else
{
$sql="SELECT member.name, selectcourse.course_date, selectcourse.coursename, selectcourse.place
FROM
`coursedata`
Inner Join `selectcourse` ON `coursedata`.`course_id` = `selectcourse`.`course_id`
Inner Join `member` ON `coursedata`.`member_id` = `member`.`member_id`
order by course_date ";
}
//echo $sql;
$dbquery = mysql_query($sql) or die ("Error Query [".$sql."]");
$Num_Rows = mysql_num_rows($dbquery);
$Per_Page = 20; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
if(!$course){
$sql .=" order by course_date DESC LIMIT $Page_Start , $Per_Page";
}
$dbquery = mysql_query($sql);
$order=1;
while($result=mysql_fetch_array($dbquery))
{
$date = $result[course_date];
list($year, $month, $day) = split('[/.-]', $date);
$date = "$day-$month-$year";
//echo $date;
echo"<tr>
<td align='center'>$order</td>
<td>$result[name]</td>
<td align='center'>$date</td>
<td> $result[coursename]</td>
<td align='center'>$result[place]</td>";
?>
</tr>
<?
$order++;
}
?>
</table>
</form>
<span style="margin-left:10px">หน้า : </span>
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'>< </a> ";
//echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< กลับ</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'> ></a> ";
//echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>ถัดไป>></a> ";
}
?>
ไม่ทราบต้องแก้ตรงไหนครับ หาไม่เจอครับ
รบก่วนพี่ๆช่วยแนะนำหน่อยครับ
ขอบคุณครับ
Tag : PHP, MySQL, HTML/CSS, JavaScript
|
|
|
|
|
|
Date :
2013-04-09 23:51:53 |
By :
Mr.mee |
View :
737 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|