yuki_365170a716 2008-8-11 11:19
多重條件組合查詢(一)
<P><BR>現在我們設想要建一個查詢系統,讓用戶即可根据訂單編號,也可根据類別,或者根据价格,或者其中的各自組合來實現快速查詢,代號如下: <BR>下面此部分是顯示查詢條件的窗体 </P>
<P><html> <BR><? <BR>$linkstr=mysql_connect("localhost","root","sa"); <BR>mysql_select_db("cx",$linkstr); <BR>?> <BR><[url=http://whatis.ctocio.com.cn/searchwhatis/425/5948925.shtml]script[/url] language="JavaScript"> <BR>function variable() <BR>{ <BR>if (document.search.select1.value!="1") <BR>{ <BR>if (document.search.no.value=="") <BR>{ <BR>window.alert("請輸入訂單號碼!"); <BR>return false; <BR>} <BR>else <BR>{ <BR>if (document.search.type.value=="") <BR>{ <BR>window.alert("請選擇配件類別!"); <BR>return false; <BR>} <BR>} <BR>} <BR>else <BR>{ <BR>if (document.search.select2.value!="1") <BR>{ <BR>if (document.search.price.value=="") <BR>{ <BR>window.alert("請輸入价格!"); <BR>return false; <BR>} <BR>} <BR>} <BR>} <BR></script> <BR><br> <BR><center><[url=http://whatis.ctocio.com.cn/searchwhatis/451/5947951.shtml]font[/url] size="5"><b>多重條件組合查詢</b></font></center> <BR><br> <BR><body> <BR><form action="searchjg.php" [url=http://whatis.ctocio.com.cn/searchwhatis/229/5948729.shtml]method[/url]="[url=http://whatis.ctocio.com.cn/searchwhatis/229/6026229.shtml]POST[/url]" name="search" onsubmit="return variable(this.value)"> <BR><[url=http://whatis.ctocio.com.cn/searchwhatis/456/6028456.shtml]table[/url] align="center" border="1" width="400"> <BR><tr> <BR><td align="left" width="100">訂單編號</td> <BR><td align="left" width="300"><input type="[url=http://whatis.ctocio.com.cn/searchwhatis/162/6092662.shtml]text[/url]" name="no"></td> <BR></tr> <BR><tr> <BR><td align="left" width="200"> <BR><select name="select1"> <BR><option selected value="1"> <BR><option value="2">或者 <BR><option value="3">而且 <BR></select>類別為 <BR></td> <BR><td align="left" width="200"> <BR><select name="type"> <BR><option selected> <BR><? <BR>$querystring="select distinct type from orders "; <BR>$result=mysql_query($querystring,$linkstr); <BR>while (list($type)=mysql_fetch_row($result)) <BR>{ <BR>echo "<option value="$type">".$type; <BR>} <BR>?> <BR></select> <BR></tr> <BR><tr> <BR><td> <BR><select name="select2"> <BR><option selected value="1"> <BR><option value="2">或者 <BR><option value="3">而且 <BR></select>价格位在 <BR></td> <BR><td><select name="price"> <BR><option selected> <BR><option value="1">50以下 <BR><option value="2">50~200? <BR><option value="3">200以上 <BR></select>的配件 <BR></td> <BR></tr> <BR><table width="400" align="right"> <BR><tr> <BR><td> <BR><input type="submit" name="submit" value="開始查詢"> <BR></td> <BR></tr> <BR></table> <BR></table> <BR></form> <BR></body> <BR></html><BR></P>