PHP头条
热点:

PHP新手想问一个站内搜索的有关问题


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'
IDCompany NameTrade nameActive IngredientPPEApplicators Must WearMixers/loaders Must WearEnvironmental HazardsCROPSREI
'.$rs->ID.''.$rs->Company_name.''.$rs->Pestcide_trade_name.''.$rs->Active_ingredient.''.$rs->PPE.'
'.$rs->AMW.'
'.$rs->MMW.'
'.$rs->EH.'
'.$rs->Crops.'
'.$rs->REI.'
';
--------------------------------------------------------------------------

www.phpzy.comtrue/phprm/55401.htmlTechArticlePHP新手想问一个站内搜索的有关问题 PHP 新手 想问一个站内搜索的问题 我刚学PHP 想做一个很简单站内搜索。 页面是这样的: -------------------------- Pestcide_trade_name: (一个下来菜单)...

相关文章

PHP之友评论

今天推荐