|
 |
|
จะทำ search option อ่าค่า แต่พอรันแล้ว ไม่โชว์ไรเรยค่ะนอกจาก error --" ช่วยดูหน่อยนะคะ |
|
 |
|
|
 |
 |
|
จะทำโค้ด search option ที่เป็นติ๊กๆอ่าค่ะ
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>
<script type="text/javascript" src="myjs.js">
</script>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</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 id=advSearch>
<tr id=advSearch><th> CATEGORY </th>
<th> COLOR </th>
<th> SIZE </th>
<th> WEARER </th>
<th> MATERIAL </th>
<td bgcolor="#000000" rowspan="2"> <input type="submit" value="GO!" </td>
</tr>
// ส่วนนี้จะรันcategory ทั้งหมดออกมาจาก db ให้หยุในรูป radio button
<tr> <td> <? $sql = "select DISTINCT c.Cat_Name, c.Cat_Id from category as c,product as p
where p.Brand_Id ='b1' and p.Cat_Id = c.Cat_Id";
$dbquery = mysql_db_query($dbname, $sql);
$num_rows = mysql_num_rows($dbquery);
$i=0;
while ($i < $num_rows)
{
$result = mysql_fetch_array($dbquery);
$cat_id = $result[Cat_Id];
$cat_name = $result[Cat_Name];
print "<input type=radio name=category value=$cat_id>$cat_name <br>";
$i++;
}
?>
</td>
// รัน color ทั้งหมดออกมาจาก db
<td> <? $sql = "select DISTINCT c.Color_Name, c.Color_Id from color as c,product as p
where p.Brand_Id ='b1' and p.Color_Id = c.Color_Id";
$dbquery = mysql_db_query($dbname, $sql);
$num_rows = mysql_num_rows($dbquery);
$i=0;
while ($i < $num_rows)
{
$result = mysql_fetch_array($dbquery);
$color_id = $result[Color_Id];
$color_name = $result[Color_Name];
print "<input type=radio name=color value=$color_id>$color_name <br>";
$i++;
}
?>
</td>
<td> size later!
</td>
// รัน wearer ทั้งหมดออกมาจาก db
<td> <? $sql = "select DISTINCT c.Wearer_Type, c.Wearer_Id from Wearer as c,product as p
where p.Brand_Id ='b1' and p.Wearer_Id = c.Wearer_Id";
$dbquery = mysql_db_query($dbname, $sql);
$num_rows = mysql_num_rows($dbquery);
$i=0;
while ($i < $num_rows)
{
$result = mysql_fetch_array($dbquery);
$wearer_id = $result[Wearer_Id];
$wearer_type = $result[Wearer_Type];
print "<input type=radio name=wearer value=$wearer_id>$wearer_type <br>";
$i++;
}
?>
</td>
//รัน material ทั้งหมดออกจาก db
<td> <? $sql = "select DISTINCT c.Mat_Name, c.Mat_Id from Material as c,product as p
where p.Brand_Id ='b1' and p.Mat_Id = c.Mat_Id";
$dbquery = mysql_db_query($dbname, $sql);
$num_rows = mysql_num_rows($dbquery);
$i=0;
while ($i < $num_rows)
{
$result = mysql_fetch_array($dbquery);
$mat_id = $result[Mat_Id];
$mat_name = $result[Mat_Name];
print "<input type=radio name=material value=$mat_id>$mat_name <br>";
$i++;
}
?>
</td>
</tr>
<tr>
<td>
//ตั้งแต่ตรงนี้เรยค่ะที่เออเร่อ ช่วยดูให้ทีค่า
<?
if($_GET["category"]!="" or $_GET["color"]!="" or $_GET["wearer"]!="" or $_GET["material"]!="")
{
sql= "SELECT * FROM product WHERE 1";
if($_GET["category"]!="")
{
sql .= "AND Cat_Id = $_GET['category']";
}
if($_GET["color"]!="")
{
sql .= "AND Color_Id = $_GET['color']";
}
if($_GET["wearer"]!="")
{
sql.= "AND Wearer_Id = $_GET['wearer']";
}
if($_GET["material"]!="")
{
sql.= "AND Mat_Id = $_GET['material']";
}
else
{
echo "Please choose your wishes!";
}
$result=mysql_query($sql);
$count=0;
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;
}
}
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2011-12-12 10:24:33 |
By :
gellarjung |
View :
805 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอา Error มาให้ดูด้วยครับ
|
 |
 |
 |
 |
Date :
2011-12-12 10:50:27 |
By :
grandraftz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Parse error: syntax error, unexpected '=' in C:\AppServ\www\advSearch.php on line 119
มันโชว์อย่างงี้อ่าค่ะะะะะ Y-Y
|
 |
 |
 |
 |
Date :
2011-12-12 11:19:24 |
By :
gellarjung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่แน่ใจ ลองเปลี่ยนเป็นแบบที่ที่บรรทัด 106
Code (PHP)
print "<input type=\"radio\" name=\"material\" value=\"$mat_id\">$mat_name <br>";
|
 |
 |
 |
 |
Date :
2011-12-12 14:44:39 |
By :
grandraftz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|