Hi,
I was wondering if anyone could help me. I have a search form on a page I'm creating, which has around 30 fields on it (in relation to computer equipment). Basically the user wants to be able to search by any of these fields and not necessarily filling in all the fields before beginning the search. So perhaps one time they will only search by inventory number, another time by key number and ip address etc. I am trying to write the php which will search using the terms supplied.
However all I can manage so far is this:
$sql = "SELECT * FROM equipment WHERE (inv_no=$inv_no,key_no=$key_no,manufacturer=$manufacturer,warranty_exp=$warranty_exp,description1=$description1,description2=$description2,model_no=$model_no,serial_no=$serial_no,location=$location,qub_class=$qub_class,date=$date,price=$price,responsibility_ctr=$responsibility_ctr,cost_centre=$cost_centre,location_code=$location_code,last_modified=$last_modified,modified_by=$modified_by,entry_date=$entry_date,supplier=$supplier,order_no=$order_no,pat_test=$pat_test,pat_due=$pat_due,test_status=$test_status,ip_address=$ip_address,ethernet_address=$ethernet_address,system_name=$system_name,network_card=$network_card,video_card=$video_card,dual_boot=$dual_boot,os=$os,memory=$memory,disk_size=$disk_size,disk_type=$disk_type,scsi_card=$scsi_card,other_cards=$other_cards,antivirus=$antivirus,maintenance=$maintenance)";
This creates errors when the user has not supplied all the fields. Can anyone help me to create a select statement which will search for only those fields supplied by the user and if the field is blank then it is not included in the search?
Thank you very much,
Karen