I have a website where you can select a row of a table and that would display another table without refreshing the page. The new table is based on a string that is converted to an array and separated based on commas.
The table is generated on the server side, not within html with php elements. I cannot seem to get the table to show all the elements of the original string, now as an array, and add them dynamically as rows.
Here is the server side code:
if (isset($_GET['query'])) {
$id = $_GET['query'];
$query = "SELECT * FROM samples_database WHERE sample_id=$id;";
$result = mysqli_query($connect, $query);
$input = mysqli_fetch_array($result);
$input1 = $input['micro_analysis'];
$rows = var_dump(explode(',', $input1));
if (count($rows) > 0) {
$output .=
'<thead>
<tr>
<th>Tests</th>
</tr>
</thead>
<tbody>';
foreach ($rows as $row): array_map('htmlentities', $row);
'<tr>
<td>'; echo implode('</td><td>', $row);
'</td>
</tr>';
endforeach;
'</tbody>';
}
echo $output;
}
In the case for better understanding the variable $input1 will look something like this:
$input1 = "1,2,44,67";
When using var_dump(explode(',', $input1)); it produces an array like this:
array(4) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(2) "44" [3]=> string(2) "67" }
So now I need the table to create under the column tests a row with "1", then a new row with "2" and so on...
Can anybody please help?