PHP 新手 想問一個站內搜尋的有關問題

來源:互聯網
上載者:User
PHP 新手 想問一個站內搜尋的問題
我剛學PHP 想做一個很簡單站內搜尋。 頁面是這樣的:

--------------------------
Pestcide_trade_name: (一個下來菜單)
Company name: (一個下拉式功能表)
Active ingredient:(一個下拉式功能表)

Application:(一個textarea)
Enviroment:(一個textarea)
-------------------------------------(上面的在資料庫的一個表裡insecticide, 下面的在表crop裡)
Crops: (一個下拉式功能表)
REI:(一個下拉式功能表)
Note: (一個textarea)

Search button

------------------------------

Pestcide_trade_name和ID 是主鍵。

資料庫一共兩張表, 上面5個在表insecticide裡,下面三個在crop裡。
我想做到的就是 Pestcide_trade_name和crop是必須選的,沒選擇要給提示要求選擇。 其他的條件可選可不選,然後結果就是把所有符合選中條件的結果顯示出來放在一個表格裡打出來。

我寫的search.php:

----------------------------------------------------------------------
if (isset($_POST['TN'])&&!empty($_POST['TN'])&&isset($_POST['Crops'])&&!empty($_POST['Crops'])){
$searchp = "select ID, Pestcide_trade_name, Crops from insecticide, crop where insecticide.Pestcide_trade_name='".$_POST['TN']."' and crop.Crops='".$_POST['Crops']."'and insecticide.ID =crop.ID ";

if(isset($_POST['CN'])&&!empty($_POST['CN']))
$searchp.="and insecticide.Company_name='".$_POST['CN']."'";
if(isset($_POST['AI'])&&!empty($_POST['AI']))
$searchp.="and insecticide.Active_ingredient='".$_POST['AI']."'";
if(isset($_POST['PPE'])&&!empty($_POST['PPE']))
$searchp.="and insecticide.PPE='".$_POST['PPE']."'";


if(isset($_POST['REI'])&&!empty($_POST['REI']))
$searchp.="and crop.REI='".$_POST['REI']."'";//and crop.Pestcide_trade_name='".$_POST['TN']."' and crop. ID = insecticide.ID";

$resultp=mysql_query($searchp);

echo"







";($rs=mysql_fetch_object($resultp)){ echo ' ';echo ' '; } echo'
ID Company Name Trade name Active Ingredient PPE Applicators Must Wear Mixers/loaders Must Wear Environmental Hazards CROPS REI
'.$rs->ID.' '.$rs->Company_name.' '.$rs->Pestcide_trade_name.' '.$rs->Active_ingredient.' '.$rs->PPE.'
'.$rs->AMW.'
'.$rs->MMW.'
'.$rs->EH.'
'.$rs->Crops.'
'.$rs->REI.'
';
--------------------------------------------------------------------------
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.