New PHP users want to ask questions about intra-site search

Source: Internet
Author: User
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"







";($ 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.'

';
--------------------------------------------------------------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.