|
 |
|
php+mySQL มี combo box ทั้งหมด 3 อัน อยากให้เป็นแบบ เลือกแค่อันใดอันหนึ่ง ก็แสดงข้อมูลได้อ่ะค่ะ (แต่ละอันดึงมาจากฐานข้อมูล) |
|
 |
|
|
 |
 |
|
ดึงอะไร --> แต่ละอันดึงมาจากฐานข้อมูล
ส่วนไหนคือยังไง ไม่มีcodeให้ดูเลย --> ต้องเขียนโค้ดยังไง แล้วเพิ่มไปที่ส่วนไหน
น้องลองทำดูแล้วติดตรงไหนมาโพสถามดีกว่านะ (เหมือนถามแบบลอยๆอะ)
|
 |
 |
 |
 |
Date :
2012-06-27 11:17:43 |
By :
LuckyStar |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นี่โค้ดทั้งหมดค่ะ เหลือแค่ตั้งให้เลือกอันใดอันหนึ่ง ก็แสดงผลได้
Code (PHP)
<?php require_once('Connections/config.php'); ?>
<?php
mysql_select_db($database_config, $config);
$query_brand = "SELECT * FROM brand ORDER BY brand ASC";
$brand = mysql_query($query_brand, $config) or die(mysql_error());
$row_brand = mysql_fetch_assoc($brand);
$totalRows_brand = mysql_num_rows($brand);
mysql_select_db($database_config, $config);
$query_type = "SELECT * FROM type ORDER BY type ASC";
$type = mysql_query($query_type, $config) or die(mysql_error());
$row_type = mysql_fetch_assoc($type);
$totalRows_type = mysql_num_rows($type);
mysql_select_db($database_config, $config);
$query_size = "SELECT * FROM `size` ORDER BY `size` ASC";
$size = mysql_query($query_size, $config) or die(mysql_error());
$row_size = mysql_fetch_assoc($size);
$totalRows_size = mysql_num_rows($size);
mysql_select_db($database_config, $config);
mysql_query("SET NAMES UTF8");
$query_brand = "SELECT * FROM brand ORDER BY brand ASC";
$brand = mysql_query($query_brand, $config) or die(mysql_error());
$row_brand = mysql_fetch_assoc($brand);
$totalRows_brand = mysql_num_rows($brand);
mysql_select_db($database_connect, $config);
mysql_query("SET NAMES 'utf-8'");
$query_brand = "SELECT * FROM brand ORDER BY brand ASC";
$brand = mysql_query($query_brand, $config) or die(mysql_error());
$row_brand = mysql_fetch_assoc($brand);
$totalRows_brand = mysql_num_rows($brand);
?>
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<title>searchmenu</title>
</head>
<style type="text/css">
<!--
.style1 {
color: #FFCC00;
font-weight: bold;
}
-->
</style>
<body>
<form method="get" action="result.php">
<table width="250" border="1" align="center" bordercolor="#333333">
<tr>
<td bordercolor="#333333" bgcolor="#FF6666"><div align="center" class="style1">Search</div></td>
</tr>
<tr>
<td><div align="center">
<p>
<select name="brand" size="1" style="width:200;">
<option value="value">Select Brand / ยี่ห้อ</option>
<?php
do {
?>
<option value="<?php echo $row_brand['brand']?>"><?php echo $row_brand['brand']?></option>
<?php
} while ($row_brand = mysql_fetch_assoc($brand));
$rows = mysql_num_rows($brand);
if($rows > 0) {
mysql_data_seek($brand, 0);
$row_brand = mysql_fetch_assoc($brand);
}
?>
</select>
</p>
<p>
<select name="type" size="1" style="width:200;">
<option value="value">Select Type / ประเภท</option>
<?php
do {
?>
<option value="<?php echo $row_type['type']?>"><?php echo $row_type['type']?></option>
<?php
} while ($row_type = mysql_fetch_assoc($type));
$rows = mysql_num_rows($type);
if($rows > 0) {
mysql_data_seek($type, 0);
$row_type = mysql_fetch_assoc($type);
}
?>
</select>
</p>
<p>
<select name="size" size="1" style="width:200;">
<option value="value">Select Size / ขนาด</option>
<?php
do {
?>
<option value="<?php echo $row_size['size']?>"><?php echo $row_size['size']?></option>
<?php
} while ($row_size = mysql_fetch_assoc($size));
$rows = mysql_num_rows($size);
if($rows > 0) {
mysql_data_seek($size, 0);
$row_size = mysql_fetch_assoc($size);
}
?>
</select>
</p>
<p>
<input name="submit" type="submit" value="SEARCH" />
</p>
</div></td>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($brand);
mysql_free_result($type);
mysql_free_result($size);
?>
|
 |
 |
 |
 |
Date :
2012-06-27 11:28:56 |
By :
phu |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยหน่อยนะคะ ><
|
 |
 |
 |
 |
Date :
2012-06-27 13:13:52 |
By :
phu |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|