change the echo "<a href=view_exp.php?compna=",$compname,">$compname</a>";
for the echo "<a href=\"view_exp.php?compna=$compname\">$compname</a>";
When using double-quoted strings, you donβt need to insert variables between them, you can simply enter them. Also, when inserting strings together, do not use a comma, but use. To insert strings, otherwise you will get parsing errors. For arrays, include them between braces {}
echo "<a href=\"view_exp.php?compna={$compname["whatever"]}\">$compname</a>";
source share