Hello pbmsc,
Welcome to WebmasterWorld!
Try this:-
while($row = mysql_fetch_array($result))
{
echo "<tr>\n\r";
echo "<td>".$row['pr_id']."</td>\n\r";
echo "<td>".$row['cat_id']."</td>\n\r";
echo "<td>".$row['pr_name']."</td>\n\r";
echo "<td>".$row['pr_des']."</td>\n\r";
echo "<td>".$row['pr_price']."</td>\n\r";
echo "<td><a href=\"view_details.php?productid=\".$row['pr_id']."\"> Details</td>\n\r"; (line 30)
echo "</tr>\n\r";
}
echo "</table>\n\r";
echo "<br/>\n\r";
mysql_close($con);//Don't need this...It's a self closing function - see note further down ;)
?>
Something like that anyway, doing the toothpick syndrome (=\") has always been a dodgy way to code html with php interwoven - have a read up on
heredoc [php.net] and other ways of string integration - very useful
Also, the use of
mysql_close() [uk2.php.net] as quoted in the manual - "isn't usually necessary.."
But for the actual coding faux pas, this was the cause:-
echo "<td>"
. <a href=\"view_details.php?productid=$row['pr_id'].\">
Corrected version:-
echo "<td><a href=\"view_details.php?productid=\
".$row['pr_id']."\"> Details</td>\n\r";
Only jumping into php so that I can echo the value of 'pr_id' and append it to the '?productid=' section in the query string.. which is what you want :)
Basically you were trying to jump into php too quickly, so the parser threw the error, just wondering though, are you using any error reporting at this stage at all? Highly recommended that you have this instruction at the top of your file:-
<?php
//set error reporting level
error_reporting(E_ALL);
Lastly, I added \n\r to the end of all of those lines so that if you were to view this executed code in the 'page source' you wouldn't have 1 huge line of code there in front of you!
Hope that helps you a bit anyway.
Cheers,
MRb