$user_id = mysql_real_escape_string( $user_id );
$current_goam = mysql_real_escape_string( $current_goam );
$usernotes = mysql_query( "SELECT title , goam
FROM notes
WHERE user_id='{$user_id}'
AND goam='{$current_goam}'
GROUP BY title" );
# Personal preference here - I always user caps for the MySQL prowords,
# and I also like breaking it across lines for easy reading
print '<table border="1" cellspacing="5">';
while( $info = mysql_fetch_array( $usernotes ) )
{
$linkURL = "mainpage.php?goam_id={$info['goam']}¬e_id={$info['title']}";
$linkTXT = $info['title'];
# Again, personal preference...
print "<tr><td><a href='{$linkURL}'>{$linkTXT}</a></td></tr>";
# Removed orphan "<td></td>" from outside of table row tags
}
print '</table>';
OR, as the goam
value is already set before you even do a query:
$user_id = mysql_real_escape_string( $user_id );
$unsanitized_goam = $current_goam;
$current_goam = mysql_real_escape_string( $current_goam );
$usernotes = mysql_query( "SELECT DISTINCT( title )
FROM notes
WHERE user_id='{$user_id}'
AND goam='{$current_goam}'" );
# Personal preference here - I always user caps for the MySQL prowords,
# and I also like breaking it across lines for easy reading
print '<table border="1" cellspacing="5">';
while( $info = mysql_fetch_array( $usernotes ) )
{
$linkURL = "mainpage.php?goam_id={$unsanitized_goam}¬e_id={$info['title']}";
$linkTXT = $info['title'];
# Again, personal preference...
print "<tr><td><a href='{$linkURL}'>{$linkTXT}</a></td></tr>";
# Removed orphan "<td></td>" from outside of table row tags
}
print '</table>';