The error is on the line:
$query . " WHERE **LOCAL = (" . $selectedOption . " AND net = " . $selectedOption2 . ")**";
remove the parentheses in the call, put it like this:
$query . " WHERE **LOCAL IN (" . $selectedOption . ") AND net = '" . $selectedOption2 . "'**";
MYSQL: WHERE column_name IN (SELECT STATEMENT);
Simplify this code:
$query = "SELECT * from SALDO_GERAL";
$i = 0;
$selectedOptionCount = count($_POST['LOCAL']);
$selectedOptionCount2 = count($_POST['net']);
$selectedOption = "";
$selectedOption2 = "";
while ($i < $selectedOptionCount) {
$selectedOption = $selectedOption . "'" . $_POST['LOCAL'][$i] . "'";
$selectedOption2 = $selectedOption2 . "'" . $_POST['net'][$i] . "'";
if ($i < $selectedOptionCount - 1) {
$selectedOption = $selectedOption . ", ";
}
$i ++;
}
Tip:
Concatenate using ' .= ' instead of repeating the variable:
$query = "SELECT * from SALDO_GERAL";
$i = 0;
$selectedOptionCount = count($_POST['LOCAL']);
$selectedOptionCount2 = count($_POST['net']);
$selectedOption = "";
$selectedOption2 = "";
while ($i < $selectedOptionCount) {
$selectedOption .= "'" . $_POST['LOCAL'][$i] . "'";
$selectedOption2 .= "'" . $_POST['net'][$i] . "'";
if ($i < $selectedOptionCount - 1) {
$selectedOption .= ", ";
}
$i ++;
}
or uses php -> implode native function():
$query = "SELECT * from SALDO_GERAL";
if ( is_array( $_POST['LOCAL'] ) ){
$selectedOption = "'" . implode("', '", $_POST['LOCAL']) . "'";
}
if ( is_array( $_POST['net'] ) ){
$selectedOption2 = "'" . implode("', '", $_POST['net']) . "'";
}
Dude, for starters, why are you setting the query at the beginning of the code to only then concatenate to the WHERE clauses? and you pricisa pass more information about your code and about the error presented
– Marcos Vinicius