ช่วยดูหน่อยครับ error
Moderator: mindphp, ผู้ดูแลกระดาน
-
- PHP Jr. Member
- โพสต์: 13
- ลงทะเบียนเมื่อ: 28/07/2008 12:31 am
ช่วยดูหน่อยครับ error
$sql="select * from car_info where status_car=1";
if($date_over>=$date_today){
$sql="update car_info set status_car='4' where id_car='$id_car' ";
$result=mysql_db_query ($dbname , $sql);}
while ($r=mysql_fetch_array ($result)) { <<< บรรทัดที่ 161
$id_car=$r [id_car];
$detail=$r [detail];
$date=$r [date];
$brand=$r [brand];
$model=$r [model];
$date_over=strtotime($r[date_over]);
$date_today=strtotime(date("Y-m-d"));
แต่มันerror
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\car\car_list.php on line 161
ไม่ทราบว่าผมควรทำยังไงดีครับ
if($date_over>=$date_today){
$sql="update car_info set status_car='4' where id_car='$id_car' ";
$result=mysql_db_query ($dbname , $sql);}
while ($r=mysql_fetch_array ($result)) { <<< บรรทัดที่ 161
$id_car=$r [id_car];
$detail=$r [detail];
$date=$r [date];
$brand=$r [brand];
$model=$r [model];
$date_over=strtotime($r[date_over]);
$date_today=strtotime(date("Y-m-d"));
แต่มันerror
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\car\car_list.php on line 161
ไม่ทราบว่าผมควรทำยังไงดีครับ
- mindphp
- ผู้ดูแลระบบ MindPHP
- โพสต์: 41231
- ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
- ติดต่อ:
Re: ช่วยดูหน่อยครับ error
โค้ด: เลือกทั้งหมด
$sql="update car_info set status_car='4' where id_car='$id_car' ";
$result=mysql_db_query ($dbname , $sql);
มันจะไม่คืน result ที่เป็นข้อมูลให้เอาไป fetch ค่าใส่ array ได้ครับ
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
-
- PHP Jr. Member
- โพสต์: 13
- ลงทะเบียนเมื่อ: 28/07/2008 12:31 am
Re: ช่วยดูหน่อยครับ error
ไม่ติดerrorแล้วครับ แต่ค่าไม่อัพเดทให้ครับ ตอนนี้แก้เป็นแบบนี้ครับ
$sql="select * from car_info where status_car=1";
while ($r=mysql_fetch_array ($result)) {
$id_car=$r [id_car];
$detail=$r [detail];
$date=$r [date];
$brand=$r [brand];
$model=$r [model];
$year=$r [year];
$color=$r [color];
$gear=$r [gear];
$price=$r [price];
$image1=$r [image1];
$image2=$r [image2];
$image3=$r [image3];
$image4=$r [image4];
$image5=$r [image5];
$image6=$r [image6];
$date_over=strtotime($r[date_over]);
$date_today=strtotime(date("Y-m-d"));
if($date_over>=$date_today){
$sql="update car_info set status_car='4' where id_car='$id_car' ";
$result_=mysql_db_query ($dbname , $sql);}
ปล.รบกวนอธิบายแบบพื้นๆได้มั้ยครับ ไม่ค่อยเข้าใจครับ (โปรเจ็คจบครับ)
ปล2.ขอบคุณมากๆครับ
$sql="select * from car_info where status_car=1";
while ($r=mysql_fetch_array ($result)) {
$id_car=$r [id_car];
$detail=$r [detail];
$date=$r [date];
$brand=$r [brand];
$model=$r [model];
$year=$r [year];
$color=$r [color];
$gear=$r [gear];
$price=$r [price];
$image1=$r [image1];
$image2=$r [image2];
$image3=$r [image3];
$image4=$r [image4];
$image5=$r [image5];
$image6=$r [image6];
$date_over=strtotime($r[date_over]);
$date_today=strtotime(date("Y-m-d"));
if($date_over>=$date_today){
$sql="update car_info set status_car='4' where id_car='$id_car' ";
$result_=mysql_db_query ($dbname , $sql);}
ปล.รบกวนอธิบายแบบพื้นๆได้มั้ยครับ ไม่ค่อยเข้าใจครับ (โปรเจ็คจบครับ)
ปล2.ขอบคุณมากๆครับ
- mindphp
- ผู้ดูแลระบบ MindPHP
- โพสต์: 41231
- ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
- ติดต่อ:
Re: ช่วยดูหน่อยครับ error
Boattysung เขียน:ไม่ติดerrorแล้วครับ แต่ค่าไม่อัพเดทให้ครับ ตอนนี้แก้เป็นแบบนี้ครับ
$sql="select * from car_info where status_car=1";
while ($r=mysql_fetch_array ($result)) {
$id_car=$r [id_car];
$detail=$r [detail];
$date=$r [date];
$brand=$r [brand];
$model=$r [model];
$year=$r [year];
$color=$r [color];
$gear=$r [gear];
$price=$r [price];
$image1=$r [image1];
$image2=$r [image2];
$image3=$r [image3];
$image4=$r [image4];
$image5=$r [image5];
$image6=$r [image6];
$date_over=strtotime($r[date_over]);
$date_today=strtotime(date("Y-m-d"));
if($date_over>=$date_today){
$sql="update car_info set status_car='4' where id_car='$id_car' ";
$result_=mysql_db_query ($dbname , $sql);}
ปล.รบกวนอธิบายแบบพื้นๆได้มั้ยครับ ไม่ค่อยเข้าใจครับ (โปรเจ็คจบครับ)
ปล2.ขอบคุณมากๆครับ
โค้ด: เลือกทั้งหมด
$sql="select * from car_info where status_car=1";
while ($r=mysql_fetch_array ($result)) {
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
-
- PHP Jr. Member
- โพสต์: 13
- ลงทะเบียนเมื่อ: 28/07/2008 12:31 am
Re: ช่วยดูหน่อยครับ error
สั่ง query แล้วครับ แต่ยังติด error อยู่เลย ไม่ทราบว่าทำผิดหรือเปล่าครับ
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\car\car_list.php on line 158
ขอโทษที่ผมต้องรบกวนนะครับ ไม่รู้จะพึ่งใครได้
ขอบคุณมากๆครับ
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\car\car_list.php on line 158
ขอโทษที่ผมต้องรบกวนนะครับ ไม่รู้จะพึ่งใครได้
ขอบคุณมากๆครับ
โค้ด: เลือกทั้งหมด
$sql="select * from car_info where status_car=1";
$result=mysql_db_query ($dbname,$sql);
while ($r=mysql_fetch_array ($result)) {
$id_car=$r [id_car];
$detail=$r [detail];
$date=$r [date];
$brand=$r [brand];
$model=$r [model];
$year=$r [year];
$color=$r [color];
$gear=$r [gear];
$price=$r [price];
$image1=$r [image1];
$image2=$r [image2];
$image3=$r [image3];
$image4=$r [image4];
$image5=$r [image5];
$image6=$r [image6];
$date_over=strtotime($r[date_over]);
$date_today=strtotime(date("Y-m-d"));
if($date_over>=$date_today){
$sql_update="update car_info set status_car='4' where id_car='$id_car' ";
$result_update=mysql_db_query ($dbname , $sql_update);
}
- mindphp
- ผู้ดูแลระบบ MindPHP
- โพสต์: 41231
- ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
- ติดต่อ:
Re: ช่วยดูหน่อยครับ error
คำสั่ง sql ที่สั่ง query อาจผิดพลาด หรือ มีข้อผิดพลาดก่อนหน้านั้น
ลอง echo $sql ไปรัน ที่ phpmyadmin ดูครับ
ถ้าได้แสดงว่ามีการผิดพลาดที่ตำแหน่งอื่น
ลองเช็คค่าตัวแปล $dbname ด้วย
เช็คว่า ติดต่อฐานข้อมูลได้แล้วหรือยัง
ลอง echo $sql ไปรัน ที่ phpmyadmin ดูครับ
ถ้าได้แสดงว่ามีการผิดพลาดที่ตำแหน่งอื่น
ลองเช็คค่าตัวแปล $dbname ด้วย
เช็คว่า ติดต่อฐานข้อมูลได้แล้วหรือยัง
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
-
- PHP Jr. Member
- โพสต์: 13
- ลงทะเบียนเมื่อ: 28/07/2008 12:31 am
Re: ช่วยดูหน่อยครับ error
ลองเช็คตัวแปลแล้วครับ สรุปว่าตัวแปร$dbnameผิดเปลี่ยนตัวแปรใหม่แล้ว แต่ยังติด error ไม่สามารถอัพเดทได้mindphp เขียน:คำสั่ง sql ที่สั่ง query อาจผิดพลาด หรือ มีข้อผิดพลาดก่อนหน้านั้น
ลอง echo $sql ไปรัน ที่ phpmyadmin ดูครับ
ถ้าได้แสดงว่ามีการผิดพลาดที่ตำแหน่งอื่น
ลองเช็คค่าตัวแปล $dbname ด้วย
เช็คว่า ติดต่อฐานข้อมูลได้แล้วหรือยัง
ลอง echo $sql ไปรัน ที่ phpmyadmin แล้วครับทุกอย่างถูกต้องไม่มีปัญหาครับ
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\car\car_list.php on line 157
-
- PHP Jr. Member
- โพสต์: 13
- ลงทะเบียนเมื่อ: 28/07/2008 12:31 am
Re: ช่วยดูหน่อยครับ error
อันนี้คือ code ทั้งหมดครับ
<?
function ConnectDB()
{
$sql_server = "localhost";
$sql_username = "root";
$sql_password = "123456";
$sql_database = "car_online";
$db = mysql_connect($sql_server, $sql_username, $sql_password) or die ("cannot connect server");
mysql_select_db($sql_database, $db) or die ("cannot connect database");
mysql_query("SET NAMES TIS620"); //แสดงผลภาษาไทย
}
ConnectDB();
include "chksession.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>.::Car List::.</title>
<style type="text/css">
<!--
.style2 {font-size: 16px}
.style3 {font-size: 16px; font-weight: bold; }
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="mailing_list_check.php">
<table width="1010" border="0" align="center">
<tr>
<td colspan="8"><div align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shoc ... n=7,0,19,0" width="1024" height="200">
<param name="movie" value="pic/logo.swf" />
<param name="quality" value="high" />
<embed src="pic/logo.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="1024" height="200"></embed>
</object>
</div> <div align="center"><img src="pic/user_menu.jpg" width="1024" height="30" border="0" usemap="#Map" longdesc="pic/user_menu.jpg" />
<map name="Map" id="Map"><area shape="rect" coords="485,-2,621,58" href="search.php" /><area shape="rect" coords="170,-1,294,37" href="new.php" /><area shape="rect" coords="300,-1,478,38" href="car_list.php" /><area shape="rect" coords="635,0,856,37" href="contact.php" />
<area shape="rect" coords="20,-1,165,38" href="profile.php" />
<area shape="rect" coords="861,0,996,37" href="logout.php" />
</map>
</div></td>
</tr>
<tr>
<td colspan="8"><div align="center"><img src="pic/1.jpg" width="1024" height="4" longdesc="pic/1.jpg" /></div></td>
</tr>
<tr>
<td colspan="8"><div align="center"><img src="pic/logo.jpg" width="996" height="48" border="0" usemap="#Map4" longdesc="pic/logo.jpg" />
<map name="Map4" id="Map4">
<area shape="rect" coords="907,2,983,46" href="saab.php" />
<area shape="rect" coords="822,2,908,46" href="audi.php" />
<area shape="rect" coords="744,2,823,46" href="ford.php" />
<area shape="rect" coords="657,2,745,46" href="volvo.php" />
<area shape="rect" coords="581,2,658,46" href="bmw.php" />
<area shape="rect" coords="496,2,582,46" href="benz.php" />
<area shape="rect" coords="417,2,497,46" href="isuzu.php" />
<area shape="rect" coords="330,1,418,46" href="mazda.php" />
<area shape="rect" coords="250,1,331,46" href="mitsubishi.php" />
<area shape="rect" coords="172,1,251,46" href="nissan.php" />
<area shape="rect" coords="84,1,173,46" href="honda.php" />
<area shape="rect" coords="8,1,85,46" href="toyota.php" />
</map>
</div>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div> <div align="center"></div></td>
</tr>
<tr>
<td colspan="8"><div align="center"><img src="pic/1.jpg" width="1024" height="4" longdesc="pic/1.jpg" /></div></td>
</tr>
<tr>
<td colspan="8"><div align="center"><img src="pic/car_list.jpg" width="1024" height="30" longdesc="pic/car_list.jpg" /></div></td>
</tr>
<tr>
<td width="127"> </td>
<td width="136"> </td>
<td width="110"> </td>
<td width="111"> </td>
<td width="173"> </td>
<td width="100"> </td>
<td width="125"> </td>
<td width="114"> </td>
</tr>
<tr>
<td colspan="8" class="style3">
<?
$sql = "SELECT * FROM car_info WHERE status_car=1 ORDER BY id_car DESC ";
////////////// กำหนดจำนวนข้อมูลแสดงผลต่อ 1 หน้า //////////////////////
$per_page = 10;
//////////////////////////////////////////////////////////////////////////////////
if ( !$page )
$page = 1;
$prev_page = $page - 1;
$next_page = $page + 1;
$result = mysql_query( $sql );
$page_start = ( $per_page * $page) - $per_page;
$num_rows = mysql_num_rows( $result );
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 ( ( $page > $num_pages ) || ( $page < 0 ) )
print "จำนวน $page มากกว่า $num_pages";
/////////////// คำสั่ง SQL กำหนดลิมิต ให้แสดงผลต่อ 1 หน้า///////////////////////////////
$sql .= " LIMIT $page_start, $per_page";
$result = mysql_query( $sql );
?>
รวมทั้งหมด <?php echo $num_rows; ?> รายการ <?php echo $num_pages; ?> หน้า :
<?php
////////////////// สร้างปุ่มย้อนกลับ ///////////////////////////////
if ( $prev_page )
echo "<a href=\"$PHP_SELF?page=$prev_page\" class='text11'><img src='pic/prev'BORDER='0'></a>";
////////////////// สร้างตัวเลขหน้า ////////////////////////////////
for ( $i=1; $i<=$num_pages; $i++ )
{
if ( $i != $page)
echo "<a href=\"$PHP_SELF?page=$i\" class='text11'>$i</a>";
else
echo " <b>$i</b> ";
}
/////////////////// สร้างปุ่มเดินหน้า /////////////////////////////////////
if ( $page != $num_pages )
echo "<a href=\"$PHP_SELF?page=$next_page\"><img src='pic/next'BORDER='0'></a>" ; ?> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?
$result=mysql_db_query ($sql_database, $sql);
while ($r=mysql_fetch_array ($result)) {
$id_car=$r [id_car];
$detail=$r [detail];
$date=$r [date];
$brand=$r [brand];
$model=$r [model];
$year=$r [year];
$color=$r [color];
$gear=$r [gear];
$price=$r [price];
$image1=$r [image1];
$image2=$r [image2];
$image3=$r [image3];
$image4=$r [image4];
$image5=$r [image5];
$image6=$r [image6];
$date_over=strtotime($r[date_over]);
$date_today=strtotime(date("Y-m-d"));
if($date_over<=$date_today){
$sql="update car_info set status_car='4' where id_car='$id_car' ";
$result=mysql_db_query ($sql_database, $sql);
}
if ($image1==""){
$image1= noimg;
}
if ($image2==""){
$image2= noimg;
}
if ($image3==""){
$image3= noimg;
}
if ($image4==""){
$image4= noimg;
}
if ($image5==""){
$image5= noimg;
}
if ($image6==""){
$image6= noimg;
}
?>
<tr>
<td> </td>
<td colspan="2" rowspan="3" bgcolor="#DEF0FE"><div align="center">
<?
echo " <center><img src='images_small/$image1'>";
?> </div></td>
<td bgcolor="#DEF0FE" class="style2"><strong>ยี่ห้อ</strong></td>
<td bgcolor="#DEF0FE"><?=$brand ?></td>
<td bgcolor="#DEF0FE" class="style3">สี </td>
<td bgcolor="#DEF0FE"><?=$color?></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#DEF0FE" class="style3">รุ่น</td>
<td bgcolor="#DEF0FE"><?=$model?></td>
<td bgcolor="#DEF0FE" class="style3">ราคา</td>
<td bgcolor="#DEF0FE"><?=number_format ((($price*5)/100)+$price);?> บาท</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#DEF0FE" class="style3">ปี</td>
<td bgcolor="#DEF0FE"><?=$year?></td>
<td bgcolor="#DEF0FE" class="style3">รายละเอียด</td>
<td bgcolor="#DEF0FE"><?="<A HREF='view_car.php?id_view=$id_car' TARGET ='_blank'><img src='pic/more'BORDER='0'></a>"?></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="6"> </td>
<td> </td>
</tr>
<?
}
?> <tr>
<td colspan="8"><div align="center"><img src="pic/end bar.jpg" width="1024" height="30" longdesc="pic/end bar.jpg" /></div></td>
</tr>
</table>
<label></label>
</form>
</body>
</html>
<?
function ConnectDB()
{
$sql_server = "localhost";
$sql_username = "root";
$sql_password = "123456";
$sql_database = "car_online";
$db = mysql_connect($sql_server, $sql_username, $sql_password) or die ("cannot connect server");
mysql_select_db($sql_database, $db) or die ("cannot connect database");
mysql_query("SET NAMES TIS620"); //แสดงผลภาษาไทย
}
ConnectDB();
include "chksession.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>.::Car List::.</title>
<style type="text/css">
<!--
.style2 {font-size: 16px}
.style3 {font-size: 16px; font-weight: bold; }
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="mailing_list_check.php">
<table width="1010" border="0" align="center">
<tr>
<td colspan="8"><div align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shoc ... n=7,0,19,0" width="1024" height="200">
<param name="movie" value="pic/logo.swf" />
<param name="quality" value="high" />
<embed src="pic/logo.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="1024" height="200"></embed>
</object>
</div> <div align="center"><img src="pic/user_menu.jpg" width="1024" height="30" border="0" usemap="#Map" longdesc="pic/user_menu.jpg" />
<map name="Map" id="Map"><area shape="rect" coords="485,-2,621,58" href="search.php" /><area shape="rect" coords="170,-1,294,37" href="new.php" /><area shape="rect" coords="300,-1,478,38" href="car_list.php" /><area shape="rect" coords="635,0,856,37" href="contact.php" />
<area shape="rect" coords="20,-1,165,38" href="profile.php" />
<area shape="rect" coords="861,0,996,37" href="logout.php" />
</map>
</div></td>
</tr>
<tr>
<td colspan="8"><div align="center"><img src="pic/1.jpg" width="1024" height="4" longdesc="pic/1.jpg" /></div></td>
</tr>
<tr>
<td colspan="8"><div align="center"><img src="pic/logo.jpg" width="996" height="48" border="0" usemap="#Map4" longdesc="pic/logo.jpg" />
<map name="Map4" id="Map4">
<area shape="rect" coords="907,2,983,46" href="saab.php" />
<area shape="rect" coords="822,2,908,46" href="audi.php" />
<area shape="rect" coords="744,2,823,46" href="ford.php" />
<area shape="rect" coords="657,2,745,46" href="volvo.php" />
<area shape="rect" coords="581,2,658,46" href="bmw.php" />
<area shape="rect" coords="496,2,582,46" href="benz.php" />
<area shape="rect" coords="417,2,497,46" href="isuzu.php" />
<area shape="rect" coords="330,1,418,46" href="mazda.php" />
<area shape="rect" coords="250,1,331,46" href="mitsubishi.php" />
<area shape="rect" coords="172,1,251,46" href="nissan.php" />
<area shape="rect" coords="84,1,173,46" href="honda.php" />
<area shape="rect" coords="8,1,85,46" href="toyota.php" />
</map>
</div>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div>
<div align="center"></div> <div align="center"></div></td>
</tr>
<tr>
<td colspan="8"><div align="center"><img src="pic/1.jpg" width="1024" height="4" longdesc="pic/1.jpg" /></div></td>
</tr>
<tr>
<td colspan="8"><div align="center"><img src="pic/car_list.jpg" width="1024" height="30" longdesc="pic/car_list.jpg" /></div></td>
</tr>
<tr>
<td width="127"> </td>
<td width="136"> </td>
<td width="110"> </td>
<td width="111"> </td>
<td width="173"> </td>
<td width="100"> </td>
<td width="125"> </td>
<td width="114"> </td>
</tr>
<tr>
<td colspan="8" class="style3">
<?
$sql = "SELECT * FROM car_info WHERE status_car=1 ORDER BY id_car DESC ";
////////////// กำหนดจำนวนข้อมูลแสดงผลต่อ 1 หน้า //////////////////////
$per_page = 10;
//////////////////////////////////////////////////////////////////////////////////
if ( !$page )
$page = 1;
$prev_page = $page - 1;
$next_page = $page + 1;
$result = mysql_query( $sql );
$page_start = ( $per_page * $page) - $per_page;
$num_rows = mysql_num_rows( $result );
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 ( ( $page > $num_pages ) || ( $page < 0 ) )
print "จำนวน $page มากกว่า $num_pages";
/////////////// คำสั่ง SQL กำหนดลิมิต ให้แสดงผลต่อ 1 หน้า///////////////////////////////
$sql .= " LIMIT $page_start, $per_page";
$result = mysql_query( $sql );
?>
รวมทั้งหมด <?php echo $num_rows; ?> รายการ <?php echo $num_pages; ?> หน้า :
<?php
////////////////// สร้างปุ่มย้อนกลับ ///////////////////////////////
if ( $prev_page )
echo "<a href=\"$PHP_SELF?page=$prev_page\" class='text11'><img src='pic/prev'BORDER='0'></a>";
////////////////// สร้างตัวเลขหน้า ////////////////////////////////
for ( $i=1; $i<=$num_pages; $i++ )
{
if ( $i != $page)
echo "<a href=\"$PHP_SELF?page=$i\" class='text11'>$i</a>";
else
echo " <b>$i</b> ";
}
/////////////////// สร้างปุ่มเดินหน้า /////////////////////////////////////
if ( $page != $num_pages )
echo "<a href=\"$PHP_SELF?page=$next_page\"><img src='pic/next'BORDER='0'></a>" ; ?> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?
$result=mysql_db_query ($sql_database, $sql);
while ($r=mysql_fetch_array ($result)) {
$id_car=$r [id_car];
$detail=$r [detail];
$date=$r [date];
$brand=$r [brand];
$model=$r [model];
$year=$r [year];
$color=$r [color];
$gear=$r [gear];
$price=$r [price];
$image1=$r [image1];
$image2=$r [image2];
$image3=$r [image3];
$image4=$r [image4];
$image5=$r [image5];
$image6=$r [image6];
$date_over=strtotime($r[date_over]);
$date_today=strtotime(date("Y-m-d"));
if($date_over<=$date_today){
$sql="update car_info set status_car='4' where id_car='$id_car' ";
$result=mysql_db_query ($sql_database, $sql);
}
if ($image1==""){
$image1= noimg;
}
if ($image2==""){
$image2= noimg;
}
if ($image3==""){
$image3= noimg;
}
if ($image4==""){
$image4= noimg;
}
if ($image5==""){
$image5= noimg;
}
if ($image6==""){
$image6= noimg;
}
?>
<tr>
<td> </td>
<td colspan="2" rowspan="3" bgcolor="#DEF0FE"><div align="center">
<?
echo " <center><img src='images_small/$image1'>";
?> </div></td>
<td bgcolor="#DEF0FE" class="style2"><strong>ยี่ห้อ</strong></td>
<td bgcolor="#DEF0FE"><?=$brand ?></td>
<td bgcolor="#DEF0FE" class="style3">สี </td>
<td bgcolor="#DEF0FE"><?=$color?></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#DEF0FE" class="style3">รุ่น</td>
<td bgcolor="#DEF0FE"><?=$model?></td>
<td bgcolor="#DEF0FE" class="style3">ราคา</td>
<td bgcolor="#DEF0FE"><?=number_format ((($price*5)/100)+$price);?> บาท</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#DEF0FE" class="style3">ปี</td>
<td bgcolor="#DEF0FE"><?=$year?></td>
<td bgcolor="#DEF0FE" class="style3">รายละเอียด</td>
<td bgcolor="#DEF0FE"><?="<A HREF='view_car.php?id_view=$id_car' TARGET ='_blank'><img src='pic/more'BORDER='0'></a>"?></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="6"> </td>
<td> </td>
</tr>
<?
}
?> <tr>
<td colspan="8"><div align="center"><img src="pic/end bar.jpg" width="1024" height="30" longdesc="pic/end bar.jpg" /></div></td>
</tr>
</table>
<label></label>
</form>
</body>
</html>
- mindphp
- ผู้ดูแลระบบ MindPHP
- โพสต์: 41231
- ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
- ติดต่อ:
Re: ช่วยดูหน่อยครับ error
$id_car=$r [id_car];
แก้เป็น
$id_car=$r[id_car];
ถ้าแก้ได้แล้ว คิดเงินด้วยนะครับ ง่ะๆ
แก้เป็น
$id_car=$r[id_car];
ถ้าแก้ได้แล้ว คิดเงินด้วยนะครับ ง่ะๆ
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
-
- PHP Jr. Member
- โพสต์: 13
- ลงทะเบียนเมื่อ: 28/07/2008 12:31 am
Re: ช่วยดูหน่อยครับ error
ลองแก้แล้วครับ อาการเดิมครับmindphp เขียน:$id_car=$r [id_car];
แก้เป็น
$id_car=$r[id_car];
ถ้าแก้ได้แล้ว คิดเงินด้วยนะครับ ง่ะๆ
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\car\car_list.php on line 155
โค้ด: เลือกทั้งหมด
$id_car=$r[id_car];
$detail=$r[detail];
$date=$r[date];
$brand=$r[brand];
$model=$r[model];
$year=$r[year];
$color=$r[color];
$gear=$r[gear];
$price=$r[price];
$image1=$r[image1];
$image2=$r[image2];
$image3=$r[image3];
$image4=$r[image4];
$image5=$r[image5];
$image6=$r[image6];
$date_over=strtotime($r[date_over]);
$date_today=strtotime(date("Y-m-d"));
ถ้าแก้ได้แล้ว คิดเงินมาได้เลยครับ แต่อย่าแพงนะครับ
-
- Similar Topics
- ตอบกลับ
- แสดง
- โพสต์ล่าสุด
-
- 1 ตอบกลับ
- 2689 แสดง
-
โพสต์ล่าสุด โดย mindphp
20/07/2019 11:59 am
-
- 1 ตอบกลับ
- 1483 แสดง
-
โพสต์ล่าสุด โดย mindphp
05/02/2022 3:09 pm
-
- 3 ตอบกลับ
- 5576 แสดง
-
โพสต์ล่าสุด โดย mindphp
31/05/2019 2:11 pm
-
-
โพสต์ใหม่ แก้ปัญหา mysql [ERROR] /usr/sbin/mysqld: Error writing file '.pid' (Errcode: 28)
โดย mindphp » 04/10/2014 4:04 am » ใน Linux - Web Server - 0 ตอบกลับ
- 2027 แสดง
-
โพสต์ล่าสุด โดย mindphp
04/10/2014 4:04 am
-
ผู้ใช้งานขณะนี้
สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 104