I have a PHP file named with Set of HTML codes, this code is to show several ID of location to be selected for the next process (Form is GET).
$sqloc = mysql_query("SELECT loc_id FROM location");
while ($row = mysql_fetch_array($sqloc)){
echo "<tr><td>
<label><input type=\"checkbox\" name=\"chk_loc[]\" value=". $row['loc_id'] ." />
</td><td>" . $row['loc_id'] . "</td></tr></label>"; }
Then in other PHP file i use this code to select data based on selected ID using checkbox before.
$cbarray = array();
if (isset($_GET['submit_location'])) {
$cbarray = $_GET['chk_loc']; }
for ($i=0; $i<count($cbarray); $i++) {
$sqlcb = mysql_query("SELECT * FROM location WHERE loc_id = '$cbarray'");
while($ccb= mysql_fetch_row($sqlcb)) {
print_r($ccb); }
}
But when i run it, it appear the notice :
Array to string conversion in .... on line 62
On line 62 which is on ($sqlcb = mysql_query) part. I already use var_dump to check the array, and it print the array like this :
array(4) { [0]=> string(5) "LO001" [1]=> string(5) "LO003" [2]=> string(5) "LO004" [3]=> string(5) "LO005" }
Is there anyway to solve this problem? thank you.