|
|
|
ช่วยดู error ให้หน่อยนะคะ คือทำ search โดยให้ใส่ keyword เข้าไปอ่ะค่ะ แต่พอรันออกมาแล้วมันขึ้นเออเร่ออ่าค่ะ ก็ไม่รู้ว่าต้องแก้ตรงไหน.. |
|
|
|
|
|
|
|
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=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
<script type="text/javascript" src="myjs.js">
</script>
<script type="text/javascript" src="framework.js">
</script>
<script>
function addCart(id){
var data = "id=" + id;
var url = "add_cart.php";
ajaxLoad('post', url, data, "cart");
}
function readCart() {
ajaxLoad('post', "read_cart.php", null, "cart");
}
</script>
</head>
<body>
<div>
<? include('menubar.php'); ?>
</div>
<? include('onlineshop.inc.php');?>
<table width="1000" align="center" border="0">
<tr>
<td align="left"> <? include('sidemenu.php');?>
<table id="cart" bgcolor="#FF0066">
<tr> <td> <script> readCart(); </script> </td></tr>
</table>
</td>
<td>
<table width="100%" border="0">
<tr> <td width="30%"> </td>
<td width="50%"> </td>
<td> </td>
</tr>
<?php include("paging.inc.php");
$current_page=1;
if(isset($_GET['page']))
{
$current_page=$_GET['page'];
}
$rows_per_page = 9;
$start_row = paging_start_row($current_page,$rows_per_page);
$keyword=$_GET["search"];
if($keyword != "") // ตรงนี้นะคะที่จะเช็คว่ายูเซอร์พิม keyword เข้ามารึเปล่า
{
$argId=$_GET["search"];
$sql = "select distinct (Product_Name)from product as p,wearer as w ,category as t, brand as b,Color as c,material as m,size as s
where p.Product_Name like '%".$argId."%'
or p.Product_Prices like '%".$argId."%'
or p.Product_Des like '%".$argId."%'
or (w.Wearer_Description like '%".$argId."%'and w.Wearer_Id=p.Wearer_Id )
or(w.Wearer_Id=p.Wearer_Id and w.Wearer_Type like '%".$argId."%' )
or(b.Brand_Id=p.Brand_Id and b.Brand_Name like '%".$argId."%' )
or(t.Cat_Id=p.Cat_Id and t.Cat_Name like '%".$argId."%' )
or (c.Color_Id=p.Color_Id and c.Color_Name like '%".$argId."%')
or (m.Mat_Id=p.Mat_Id and m.Mat_Name like '%".$argId.a"%' )
or (s.Size_Description like '%".$argId."%' and s.Size_Id=p.Size_Id )
or (s.Size_Id=p.Size_Id and s.Size_Name like '%".$argId."%' )";
/*$sql= "SELECT SQL_CALC_FOUND_ROWS * from product, color,material, category WHERE ( (product.Product_Des LIKE '%".$argId."%') AND Size_Id='s1' LIMIT $start_row, $rows_per_page ;";*/
}
else
{
$argId=$_GET["argId"];
$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM product WHERE (Cat_Id ='$argId' OR Color_Id='$argId' OR Wearer_Id='$argId' OR Mat_Id='$argId' OR Product_Des LIKE '%".$argId."%') AND Size_Id='s1' LIMIT $start_row, $rows_per_page;";
if(strcmp($argId,"EDITOR")==0 or strcmp($argId,"FALL ")==0 or strcmp($argId,"CHILL OUT")==0 or strcmp($argId,"OFFICE LOOK")==0)
{
$sqlpic="SELECT * FROM headpic WHERE pic_name ='$argId' ;"; //for headpic
}
else
{
$sqlpic="SELECT headpic.pic_pict FROM headpic WHERE headpic.pic_name IN (SELECT category.cat_name, color.color_name, material.mat_name FROM category, color, material WHERE category.cat_Id='$argId' OR color.color_Id='$argId' OR material.mat_Id='$argId');";
}
}
//headpic section
$resultpic = mysql_query($sqlpic);
while($rowpic = mysql_fetch_array($resultpic))
{
$headpic=$rowpic['pic_pict'];
}
//headpic section
$result=mysql_query($sql);
$found_rows=mysql_query("SELECT FOUND_ROWS();");
$total_rows=mysql_result($found_rows,0,0);
$total_pages = paging_total_pages($total_rows, $rows_per_page);
if($total_rows==0){
echo "<caption><b> no result </b></caption>";
}
/*else {
$stop_row = paging_stop_row($start_row, $rows_per_page, $total_rows);
echo "<caption><b> product no.". ($start_row +1) . "-" . "$stop_row from total $total_rows </b></caption>";
} */
$count=0;
echo "<table border=0 align=center >";
echo "<tr><td colspan=3><div> <img src='$headpic'></div> </td></tr>"; //for headpic
while($objResult = mysql_fetch_array($result))
{
$PID = $objResult['Product_Id'];
$Pname = $objResult['Product_Name'];
$Pdesc1 = $objResult['Product_Des'];
$Pdesc = substr($Pdesc1,0,80). "..." ;
$Pprice = $objResult['Product_Prices'];
$Ppic = $objResult['Product_Pict'];
if($count==0)
{
echo "<tr> <td width=220 ><div id=product> <img align=center width=115 src='$Ppic?Product_Id=$PID'> </div>";
echo "<div id=productName> <br><b> <a href='product_detail.php?PID=$PID'> $Pname </a> </b></div>";
echo "<div id=product> <br> $Pdesc </div>";
echo "<div id=product> <br> $Pprice Baht</div>";
echo "<div id=product> <br> <input type=button value='add to cart' > </div>";
echo "</td>";
$count++;
}
else if($count==1)
{
echo "<td width=220 > <div id=product> <img width=115 src='$Ppic?Product_Id=$PID'> </div>";
echo "<div id=productName> <br><b><a href='product_detail.php?PID=$PID'> $Pname </a> </b> </div>";
echo "<div id=product> <br> $Pdesc </div>";
echo "<div id=product> <br> $Pprice Baht</div>";
echo "<div id=product> <br> <input type=button value='add to cart' > </div>";
echo "</td>";
$count++;
}
else if($count==2)
{
echo "<td width=220 > <div> <img width=115 src='$Ppic?Product_Id=$PID'> </div>";
echo "<div id=productName> <br><b><a href='product_detail.php?PID=$PID'> $Pname </a> </b> </div>";
echo "<div id=product> <br> $Pdesc </div>";
echo "<div id=product> <br> $Pprice Baht</div>";
echo "<div id=product> <br> <input type=button value='add to cart' > </div>";
echo "</td>";
echo "</tr>";
$count=0;
}
} echo "</table>";
?>
<p align="right"> <br />
<?php
$page_range=5;
$qry_str="argId=$argId";
//$total_pages = paging_total_pages($total_rows, $rows_per_page);
$pagenum = paging_pagenum($current_page, $total_pages, $page_range, $qry_str);
?>
<?
echo "page:" . $pagenum;
?>
</p>
</table>
</td>
</tr>
</table>
<div>
<? include('footer.php'); ?>
</div>
</body>
</html>
เออเรอร์มันออกมาเปนงี้อ่าค่ะ
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\index.php on line 134
ช่วยดูให้หน่อยนะคะ -/|\-
Tag : PHP, Ms Access
|
ประวัติการแก้ไข 2011-12-13 09:53:29 2011-12-13 09:58:24
|
|
|
|
|
Date :
2011-12-13 09:52:48 |
By :
gellarjung |
View :
764 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเขียน Check ก่อนนะครับคือ ถ้า .$argId ไม่มีการกรอกข้อมูลเข้ามา ไม่ต้องทำอะไร และถ้ากรอกข้อมูลเข้ามาค่อยค้นหานะครับประมาณนี้
|
|
|
|
|
Date :
2011-12-13 10:03:59 |
By :
ronit3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query ถูกหรือเปล่าครับ
|
|
|
|
|
Date :
2011-12-13 10:14:23 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|