I was looking for a select box that can be used for a multiple selection to determine which location I want to look for in my research, with this, an attachment to the database. So, down here, it’s what I’ve find to go through this:
I put a select box with my 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 a foreach to give me selected location :
foreach ($_GET['SelectLocation'] as $selectedOption){
//echo $selectedOption."\n";
$query1="select * from location where location_id=$selectedOption";
$info=info_query($query1);
$nomLocation=$info['location'];
$Location .= $nomLocation."\n";
}
echo $Location;
Right now, if I select, for example, Inbound and Summerside, the echo give me: Inbound Summerside This in the same line.
I use the query to go get the name in the database (the query1). I want now to use those “name”, that went I’m select my example (Inbound and Summerside), do my search, it take only the selected location, not the other one, so I made this in my 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
from 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
where computer.computer_name like '%".$critere."%' and location.location like".$Location;
My issue is : Went I do a research with my example, Inbound and Summerside, it didn’t give me any recording.
It’s because my location is in a line he can reach out in the database? I try to put the %
before and after the $Location
like $critere
, but didn’t help. Did I need to work with value and location_id if it’s not with the name of the location?
What I want, it’s that my $Location
be able to tell the location chosen to the database and went the selection work perfectly with the database, my research display with all information necessary with the selected location and criteria.
Please, if more information needed, tell me and I will 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 from 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
where computer.computer_name like '%52%' and location.location in ()