Hi all,
I need help again.
I have 2 tables, table a with 3 fields, table b with 2 fields.
here is my code:
<html>
<head>
<title>MySQL Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000">
<p>
<?php
$db = mysql_connect("localhost", "databaseusername", "password");
if (!$db)
{
echo "Unable to make a connection to the database";
exit;
}
mysql_select_db("database");
// Define a SQL Select Query
$query = "SELECT table_a.name, table_a.lyrics, table_a.al_id, table_b.name, table_b.id
FROM table_a, table_b
WHERE table_a.al_id = table_b.id
AND LENGTH(table_a.comments) > 0
ORDER by table_b.name";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<p>Number of Lyrics found: ".$num_results."</p>";
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
// Display the results of the query in a table
print "<center><table width=\"600\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n";
print "<tr><td><b>Movie</b></td><td><b>Song</b></td><td><b>Lyrics</b></td></tr>";
print "<tr><td>";
print $row['table_b.name'];
print "</td><td>";
print $row['table_a.name'];
print "</td><td>";
print " (<a href=\"$rows['table_a.lyrics']\">Link</a>;
print "</td></tr>\n";
print "</table></center>\n";
}
?>
</body>
</html>
I get the following error:
Parse error: parse error, expecting T_STRING' orT_VARIABLE' or `T_NUM_STRING' on line 45
Line 45 is: print " (<a href=\"$rows['table_a.lyrics']\">Link</a>;
If i delete this line i get a blank table with no data in any cell.
The echo for number though works = 578
Here is the table info:
table_a: name(char) lyrics(char) al_id(num)
table_b: id(num), name(char)
Basically the al_id number in table_a is the same number in id field in table_b and the table_a.lyrics field contains the absolute url to the lyrics.
What is wrong?
Thanks
Chuck