I have a 1 file with html,php and javascript. Normally in php you would perform a query like this. This is good and i want to keep.
<?php
$sql = "SELECT * FROM voedingsmiddelen";
$result = mysqli_query($conn, $sql);
?>
And then you would use this php to get the 'name' fields. This outputs "name|age|sex|birthdate|". This part below i want to do in javascript.
$count = 0;
while($row = mysqli_fetch_assoc ($result)) {
$fieldinfo = mysqli_fetch_field_direct($result,$count);
echo $fieldinfo->name;
$count++;
}
This is what i came up with but i get stuck here. I want an alert with 'name' and alert with 'sex' and alert with 'birthdate' from the database.
var arraylength=<?php echo sizeof($result)+1; ?>;
var i=0;
while(i<arraylength){
//what goes here i dunno
alert(idunnohow[i]);
i++;
}
Is this possible? And how?