php - How to pass the selected value from select box to a research -
i looking select box can used multiple selection determine location want in research, this, attachment database. so, down here, it’s i’ve find go through this:
i put select box few locations:
<select name="selectlocation[]" multiple="yes"> <option value="1">inbound</option> <option value="2">outbound</option> <option value="3">training room</option> <option value="4">summerside</option> <option value="5">alberton</option> </select>
i use foreach give me selected location :
foreach ($_get['selectlocation'] $selectedoption){ //echo $selectedoption."\n"; $query1="select * location location_id=$selectedoption"; $info=info_query($query1); $nomlocation=$info['location']; $location .= $nomlocation."\n"; } echo $location;
right now, if select, example, inbound , summerside, echo give me: inbound summerside in same line.
i use query go name in database (the query1). want use “name”, went i’m select example (inbound , summerside), search, take selected location, not other one, made in query :
location.location like".$location; $query="select computer.computer_id, computer.computer_name, computer.product_key, computer.model, computer.serial_number, `status`.`status`, computer.starphone, computer.inst_id, computer.did, computer.macaddress, software.description, vendor.vendor_name, location.location, department.department, jack.jack_number computer inner join computer_vendor on computer.computer_id=computer_vendor.computer_id inner join vendor on computer_vendor.vendor_id=vendor.vendor_id inner join `status`on computer.status_id=`status`.status_id inner join software on computer.software_id=software.software_id inner join jack on jack.computer_id=computer.computer_id inner join location on location.location_id=jack.location_id inner join department on department.dept_id=jack.dept_id computer.computer_name '%".$critere."%' , location.location like".$location;
my issue : went research example, inbound , summerside, didn’t give me recording. it’s because location in line can reach out in database? try put %
before , after $location
$critere
, didn’t help. did need work value , location_id if it’s not name of location?
what want, it’s $location
able tell location chosen database , went selection work database, research display information necessary selected location , criteria.
please, if more information needed, tell me , provide it.
select computer.computer_id, computer.computer_name, computer.product_key, computer.model, computer.serial_number, `status`.`status`, computer.starphone, computer.inst_id, computer.did, computer.macaddress, software.description, vendor.vendor_name, location.location, department.department, jack.jack_number computer inner join computer_vendor on computer.computer_id=computer_vendor.computer_id inner join vendor on computer_vendor.vendor_id=vendor.vendor_id inner join `status`on computer.status_id=`status`.status_id inner join software on computer.software_id=software.software_id inner join jack on jack.computer_id=computer.computer_id inner join location on location.location_id=jack.location_id inner join department on department.dept_id=jack.dept_id computer.computer_name '%52%' , location.location in ()
$location=array(); foreach ($_get['selectlocation'] $selectedoption){ //echo $selectedoption."\n"; $query1="select * location location_id=$selectedoption"; $info=info_query($query1); $nomlocation=$info['location']; $location[] = addslashes($nomlocation); } $locationconsolidated = "'".join("','", $location)."'";
and use $locationconsolidated ...
where computer.computer_name '%".$critere."%' , location.location in ($locationconsolidated)
Comments
Post a Comment