台灣最大程式設計社群網站
線上人數
1887
 
會員總數:246478
討論主題:189985
歡迎您免費加入會員
討論區列表 >> PHP >> 下拉式選單....查詢所要的記錄,可以請各位高手幫個忙嗎?
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
下拉式選單....查詢所要的記錄,可以請各位高手幫個忙嗎?
價值 : 20 QP  點閱數:2351 回應數:0
樓主

小靜
門外漢
0 3
68 1
發送站內信

search.php傳送到search_view.php 不好意思,我剛接觸到程式><,麻煩各位大大幫個忙,可以教我怎麼寫嗎?
我現在用的軟體是dreamweaver,我希望能做到跟這個網頁的一樣http://search.murata.co.jp/Ceramy/GrsearchAction.do?sLang=en

<?php require_once('Connections/conn_test.php'); ?>
<?php
mysql_select_db($database_conn_test, $conn_test);
$query_Recordset1 = "SELECT * FROM type";
$Recordset1 = mysql_query($query_Recordset1, $conn_test) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!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=big5" />
<title>下拉式選單</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="search_view.php">
<table width="200" border="1">
<tr>
<th width="95" scope="col"><div align="right">Type:</div></th>
<th width="89" scope="col"><label>

<select name="type" id="type">
<option value="">&nbsp;</option>
<option value="1">MLCC</option>
<option value="2">Tantalum</option>
<option value="3">OS-CON</option>
<option value="4">POSCAP</option>
<option value="5">Aluminum</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['type']?>"><?php echo $row_Recordset1['type']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select> </label> </th>
</tr>
<tr>
<td><div align="right"><strong>Vendor : </strong></div></td>
<td><label>

<select name="vendor" id="vendor">
<option value="">&nbsp;</option>
<option value="1">Murata</option>
<option value="2">AVX</option>
<option value="3">Pansonic</option>
<option value="4">Sanyo</option>
<option value="5">Chemicon</option>
<option value="6">Rubycon</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['vendor']?>"><?php echo $row_Recordset1['vendor']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select> </label></td>
</tr>
<tr>
<td><div align="right"><strong>Size:</strong></div></td>
<td><label>

<select name="size" id="size">
<option value="">&nbsp;</option>
<option value="1">0603</option>
<option value="2">0805</option>
<option value="3">3216(Case A)</option>
<option value="4">7343(Case D)</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['size']?>"><?php echo $row_Recordset1['size']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select> </label></td>
</tr>
<tr>
<td><div align="right"><strong>Cap:</strong></div></td>
<td><label>

<select name="cap" id="cap">
<option value="">&nbsp;</option>
<option value="1">0.1u</option>
<option value="2">10u</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['cap']?>"><?php echo $row_Recordset1['cap']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select> </label></td>
</tr>
<tr>
<td><div align="right"><strong>Dielectric:</strong></div></td>
<td><label>

<select name="dielectric" id="dielectric">
<option value="">&nbsp;</option>
<option value="1">X5R</option>
<option value="2">Y5V</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['dielectric']?>"><?php echo $row_Recordset1['dielectric']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select> </label></td>
</tr>
<tr>
<td><div align="right"><strong>Rated_Voltage:</strong></div></td>
<td><label>

<select name="rated_voltage" id="rated_voltage">
<option value="">&nbsp;</option>
<option value="1">6.3V</option>
<option value="2">16V</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['rated_voltage']?>"><?php echo $row_Recordset1['rated_voltage']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select> </label></td>
</tr>
<tr>
<td><div align="right"><strong>P_N:</strong></div></td>
<td><label>

<select name="p_n" id="p_n">
<option value="">&nbsp;</option>
<option value="1">GRM185R61A105KE36@3.3V</option>
<option value="2">GRM18561A105KE36@1.8V</option>
<?php
do {
?>
<option value="<?php echo $row_Recordset1['p_n']?>"><?php echo $row_Recordset1['p_n']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select> </label></td>
</tr>
<tr>
<td><div align="right"><strong>TXT:</strong></div></td>
<td><label>

<select name="txt" id="txt">
</select> </label></td>
</tr>
<tr>
<td><div align="right"><strong>PDF:</strong></div></td>
<td><label>

<select name="pdf" id="pdf">
</select> </label></td>
</tr>
</table>
<label>
<input type="submit" name="Submit" value="送出" />
</label>
</form>


</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
--------------------------------------------------------------------------------
search_view.php

<?php require_once('Connections/conn_test.php'); ?>
<?php
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

$colname_Recordset1 = "1";
if (isset($_POST['type'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_POST['type'] : addslashes($_POST['type']);
}
mysql_select_db($database_conn_test, $conn_test);
$query_Recordset1 = sprintf("SELECT * FROM type WHERE type LIKE '%%%s%%' or vendor LIKE '%%%s%%' or size LIKE '%%%s%%' or cap LIKE '%%%s%%' or dielectric LIKE '%%%s%%' or rated_voltage LIKE '%%%s%%' or p_n LIKE '%%%s%%' ", $colname_Recordset1,$colname_Recordset1,$colname_Recordset1,$colname_Recordset1,$colname_Recordset1,$colname_Recordset1,$colname_Recordset1);
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $conn_test) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>無標題文件</title>
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style10 {color: #333333}
.style7 {color: #333333; font-weight: bold; }
-->
</style>
</head>

<body>
<form method="post" name="form1">
<p>共<?php echo $totalRows_Recordset1 ?> 筆資料 </p>
<table border="1">
<tr>
<td class="style10">type</td>
<td class="style10">vendor</td>
<td class="style10">size</td>
<td class="style10">cap</td>
<td class="style10">dielectric</td>
<td class="style10">rated_voltage</td>
<td class="style10">p_n</td>
<td class="style10">txt</td>
<td class="style10">pdf</td>
</tr>
<?php do { ?>
<tr>
<td class="style7"><?php echo $row_Recordset1['type']; ?></td>
<td class="style10"><?php echo $row_Recordset1['vendor']; ?></td>
<td class="style10"><?php echo $row_Recordset1['size']; ?></td>
<td class="style10"><?php echo $row_Recordset1['cap']; ?></td>
<td class="style10"><?php echo $row_Recordset1['dielectric']; ?></td>
<td class="style10"><?php echo $row_Recordset1['rated_voltage']; ?></td>
<td class="style10"><?php echo $row_Recordset1['p_n']; ?></td>
<td class="style10"><?php if(strlen($row_Recordset1['txt']) > 0){?>
<a href="./txt/<?php echo $row_Recordset1['txt']; ?>"><img src="0.gif" width="31" height="32" border="0" />
<?php }else{echo" no file ";}?>
</a></td>
<td class="style10"><?php if(strlen($row_Recordset1['pdf']) > 0){?>
<a href="./pdf/<?php echo $row_Recordset1['pdf']; ?>"><img src="1.gif" border="0" />
<?php }else{echo" no file ";}?>
</a></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<a href="111.php">
<?php if ($totalRows_Recordset1 == 0) { // Show if recordset empty ?>
</MM:DECORATION></MM_HIDDENREGION></a>
</form>
<MM_HIDDENREGION><MM:DECORATION OUTLINE="如果有下列情況,即顯示..." OUTLINEID=2>
<p align="center" class="style1"><a href="111.php">搜尋不到相關記錄</a></p>
<a href="search.php">
<?php } // Show if recordset empty ?>
回查詢頁
</a>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

本篇文章發表於2007-06-13 23:08
目前尚無任何回覆
   

回覆
如要回應,請先登入.