I have a collection of check boxes all with the name c[] but different values. From php8 the code below works but gives me an 'Undefined variable $sql_c’ warning (perhaps this error was just suppressed in earlier versions?). I was given the code years back and have now updated it with numerous 'if isset()' functions, but if I do that to the $sql_c function, I get no results. Any help would be appreciated.
PHP:
if (isset($_POST['submit']) && isset($_POST['c'])) {
$sql="stuno,fname,lname";
if(isset($_POST['c']) && $_POST['c']=="") {$c = array(); }
foreach ($_POST['c'] as $cID) {
$sql_c .= ",".$cID; // "Undefined variable $sql_c" warning
if (isset($numCat)) {$numCat = $numCat + 1;}
}
$sql = $sql . $sql_c;
$sql="SELECT"." ".$sql." "."FROM records ORDER BY fname";
$result=@mysqli_query($dbcnx, $sql);