A beginner in PHP wants to ask a question about intra-site search. I just learned PHP and want to do a very simple intra-site search. The page is like this: ------------------------ Pestcide_trade_name :( A down menu) Companyname :( a drop-down menu) Activeingredient :( a drop-down menu) Application :( a textarea) Envi PHP beginner wants to ask a site search question
I just learned PHP and want to do a simple intra-site search. The page is as follows:
--------------------------
Pestcide_trade_name: (a down menu)
Company name: (a drop-down menu)
Active ingredient: (a drop-down menu)
Application :( a textarea)
Enviroment :( a textarea)
----------------------------------- (The preceding table is insecticide in the database, and the following table is in crop)
Crops: (a drop-down menu)
REI: (a drop-down menu)
Note: (a textarea)
Search button
------------------------------
Pestcide_trade_name and ID are the primary keys.
There are two tables in the database, five of which are in the insecticide table, and three of which are in crop.
What I want to do is that Pestcide_trade_name and crop are required. if you do not select Pestcide_trade_name or crop, you need to select the one for the prompt. Other conditions are optional, and all results that meet the selected conditions are displayed in a table.
Search. php I wrote:
----------------------------------------------------------------------
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"
ID |
Company Name |
Trade name |
Active Ingredient |
PPE |
Applicators Must Wear |
Mixers/loaders Must Wear |
Environmental Hazards |
CROPS |
REI |
";($ Rs = mysql_fetch_object ($ resultp )){ Echo'
'. $ Rs-> ID .' |
'. $ Rs-> Company_name .' |
'. $ Rs-> Pestcide_trade_name .' |
'. $ Rs-> Active_ingredient .' |
'. $ Rs-> PPE .' | ';Echo'
'.$rs->AMW.' |
'.$rs->MMW.' |
'.$rs->EH.' |
'.$rs->Crops.' |
'.$rs->REI.' |
'; }Echo'
';
--------------------------------------------------------------------------