So here is my PHP code:
$checkProject1Column = "SELECT * FROM tbl_studentchoice WHERE Project1 = '1'";
$resultProject1Column = mysqli_query($conn, $checkProject1Column);
while($row = mysqli_fetch_assoc($resultProject1Column)) {
//Create an array of students
$array[] = ['studentid' => $row['studentid']];
}
//check marks database
$checkmarks = "SELECT studentid,marks FROM tbl_marks";
$checkResult = mysqli_query($conn, $checkmarks);
if ($checkResult->num_rows >= 0){
while($row1 = mysqli_fetch_assoc($checkResult)){
//Create an array of students
$array1[] = [
'marks' => $row1['marks'],
'studentid' => $row1['studentid']
];
}
print_r($array);
print_r($array1);
So I have 2 database tables. tbl_studentchoice and tbl_marks.
I created an array of students with a value 1 on Project1 column. This is how my tbl_studentchoice looks like:
So now that I have an array of studentid's. I want to get the marks of these students from another table (tbl_marks) which looks like this:
and create a new array with only studentid with Project1 value 1 and their marks. So basically I want to create an array like this:
Array (
[0] => Array (
[studentid] => c12558111
[marks] => 50
)
[1] => Array (
[studentid] => c12558112
[marks] => 60
)
)


$resultProject1Column = mysqli_query($conn, $checkProject1Column);?