I created a function to output a table row with data from a JS file. But I'd like to retrieve data from the MySQL database I made instead. Is it possible?
Function:
function outputCartRow(name, id, email, proj_title){
document.write('<tr>');
document.write('<td>'+name+'</td>');
document.write('<td>'+id+'</td>');
document.write('<td>'+email+'</td>');
document.write('<td>'+proj_title+'</td>');
document.write('</tr>');
}
I created a separate form that submits all the textfield input to the database, for reference:
PHP text:
<?php
$conn = mysqli_connect('127.0.0.1:3307', '', '');
if(!$conn){
echo 'Missing server';
}
if(!mysqli_select_db($conn,'fyp')){
echo 'Missing database';
}
$stud_name = $_POST['stud_name'];
$stud_id = $_POST['stud_id'];
$stud_email = $_POST['stud_email'];
$proj_title = $_POST['proj_title'];
$sql = "INSERT INTO student_assignment(stud_name, stud_id, stud_email, proj_title) values ('$stud_name', '$stud_id', '$stud_email', '$proj_title')";
if(!mysqli_query($conn, $sql)){
echo 'Update error';
}
else{
echo 'Update successful';
}
header("refresh:2; url=supervisor_pa.html");
?>
Is there a way to retrieve all the data and refer it to the function?