Given below in the picture is the desired output I want. I've 3 tables, student, projects and a junction table where corresponding student ids are present against each project id.
I'm unable to group on the basis of projects, if there's any better solution for this, that'd be good. I want to show data through jquery, that's the most important thing here. Any help would be appreciated.
main.php file
$result = $con->query("
SELECT s.Name, p.Title, p.Description FROM students s LEFT JOIN projects p ON s.Student_id = p.Project_id LEFT JOIN proj_stu_junc psg ON p.Project_id = psg.Student_id");
// var_dump($result);
while($row=mysqli_fetch_assoc($result))
{
$image=$row ['Title'];
echo $image;
}
mysqli_free_result($result);
JS file
$.ajax({
type: "GET",
url: 'main.php',
dataType: 'text',
success: getfive
});
function getfive(val) {
var stuArray = val.split('\n');
stuArray.forEach(function(studentName){
$('#getfive').append('<div>'+studentName+'</div>')
});
}
Each group of project should generate a separate div.
HTML placeholder
<div class="main-container">
<div id="getfive"></div>
</div>