I have the following general mySQL query:
$query = sprintf(
"SELECT a.A,
a.B,
...,
a.C,
FROM a
WHERE a.A = %s
ORDER by a.A;",
implode(" OR a.A = ", $_SESSION['values']));
for some records, B has a value, and for others, B is NULL. That is what I want.
I extract the query with the following PHP:
for ($i = 0; $i < $nrows; $i++){
$row = mysqli_fetch_assoc($result);//fetches data stored within each row
extract($row);
echo "<tr>";
foreach($row as $column => $field){
if($field == $...){
...
}
elseif($field == $C){
echo"<td>
<input type='text' name='C+[]' value='$C'>
</td>";
}
echo "</tr>"
}
In the resulting html table, records containing not null B fields are presented accurately, while records with null B fields incur a duplication of field C. This offset occurs at the beginning of the record, pushing the final field in the record outside the table boundaries.
I think I've narrowed down the problem to the extract() function, as r_print readouts of every other variable in the script returns the accurate field names and values.
But, running print_r on $row after extract() provides an identical printout to other variables in the script.
What are some possible ways I can stop the duplication of field C from occurring? Happy to provide more information upon request.