Basically the first part of this code works fine... The problem is I simply need to print out my student table. Heres my code... the error is
Parse error: syntax error, unexpected '/' in C:\wamp\www\assignment8.php on line 57
Line 57 is : print "</tr>";
Heres my code:
<html><head><title>Assignment 8</title></head>
<body bgcolor = "Black">
<font face="arial" color = "white" size="+1">
<?php
$link = mysql_connect("localhost", "root"); // connects to localhost
$result = mysql_select_db("School"); //selects database school
if ($result)
{
print "Database selected successfully<br/>";
print "<br/>";
}
else
{
print " there was a problem with the database selection<br/>";
mysql_error();
}
$query="SELECT FirstName, LastName, Major from student";
$result_set= mysql_query($query);
while($record=mysql_fetch_row($result_set))
{
foreach ($record as $value)
{
print "<em>$value\t</em>"; //prints the row
}
print "<br/>";
}
print "<br/>";
$query = "select * from student where gpa > 3.0";
$result = mysql_query($query);
$num_rows_good_gpa = mysql_num_rows($result);
print "<b> there are a total of $num_rows_good_gpa students that have a gpa greater than 3.0<br/>";
print "<br/>";
//printing rows
print "Displaying all the rows of the database...<br/>";
$result_set = mysql_query("select * from student");
print "<table>";
//headers
for ($c=0; $c<mysql_num_fields($result_set); $c++)
{
print "<th>". mysql_field_name($result_set, $c) ."</th>";
}
while ($record = mysql_fetch_row($result_set))
{
print"<tr>";
for ($c=0; $c<mysql_num_fields($result_set); $c++)
{
print "<td>". $record[$c] ."</td>;
}
print "</tr>";
}
print "</table>";
mysql_close($link);
?>
Please offer some suggestions if you can, thanks
Parse error: syntax error, unexpected '/' in C:\wamp\www\assignment8.php on line 57
Line 57 is : print "</tr>";
Heres my code:
<html><head><title>Assignment 8</title></head>
<body bgcolor = "Black">
<font face="arial" color = "white" size="+1">
<?php
$link = mysql_connect("localhost", "root"); // connects to localhost
$result = mysql_select_db("School"); //selects database school
if ($result)
{
print "Database selected successfully<br/>";
print "<br/>";
}
else
{
print " there was a problem with the database selection<br/>";
mysql_error();
}
$query="SELECT FirstName, LastName, Major from student";
$result_set= mysql_query($query);
while($record=mysql_fetch_row($result_set))
{
foreach ($record as $value)
{
print "<em>$value\t</em>"; //prints the row
}
print "<br/>";
}
print "<br/>";
$query = "select * from student where gpa > 3.0";
$result = mysql_query($query);
$num_rows_good_gpa = mysql_num_rows($result);
print "<b> there are a total of $num_rows_good_gpa students that have a gpa greater than 3.0<br/>";
print "<br/>";
//printing rows
print "Displaying all the rows of the database...<br/>";
$result_set = mysql_query("select * from student");
print "<table>";
//headers
for ($c=0; $c<mysql_num_fields($result_set); $c++)
{
print "<th>". mysql_field_name($result_set, $c) ."</th>";
}
while ($record = mysql_fetch_row($result_set))
{
print"<tr>";
for ($c=0; $c<mysql_num_fields($result_set); $c++)
{
print "<td>". $record[$c] ."</td>;
}
print "</tr>";
}
print "</table>";
mysql_close($link);
?>
Please offer some suggestions if you can, thanks