Reputation: 11
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, i m 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>";
Upvotes: 0
Views: 50
Reputation: 1384
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>";
}
Upvotes: 0
Reputation: 74217
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'];
-------------------^
Upvotes: 1