简体   繁体   中英

printing data from two tables

So my objective was to print data from two into a standard table.

It should ideally display the name of the each distinct scholarship and its table with a list of all the students who applied for it. I m uncertain if my approach is correct.

Please help, im trying to learn the basics. Thanks in advance.

 <?php 
include_once 'function.php';
connect();

?>
<html><body>

<?php

$query = "SELECT *
FROM entry, student_details 

WHERE entry.user_id=student_details.user_id";

//run query
$result = mysql_query($query);
// creating a table


echo "<table border='1'>
<tr>
<th>Student ID</th>
<th>Student Name</th>

</tr>";

//Print the record that matches the criteria of the query
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo $row['s_name']
{
echo "<tr>";
echo "<td>" . $row['student_id'] . "</td>";
echo "<td>" . $row['student_name' ] . "</td>";
echo "</tr>";

}
}
?>

</table>
<?php close() 
?>
</body></html>

the error i get is this Parse error: syntax error, unexpected 'echo' (T_ECHO) on line echo "<tr>";

Parse error messages don't necessarily originate on the actual line number stated, but many times one line above, being this:

echo $row['s_name']
-------------------^
// missing semi-colon

You forgot to put an ending semi-colon at the end.

Modify it to look like this:

echo $row['s_name'];
-------------------^

You have a syntax error.

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo $row['s_name'];

echo "<tr>";
echo "<td>" . $row['student_id'] . "</td>";
echo "<td>" . $row['student_name' ] . "</td>";
echo "</tr>";

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM