问题
I want to give link to the retrieved value from database but the error is coming for the below code:
Print " <td>" "<a href="#">".$info['shopname'] ."</a>" "</td> ";
as
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\xampp\htdocs\test.php on line 14
So please rectify it how to apply multiple html tags in print statement
回答1:
Can you try this,
echo " <td><a href='#'>".$info['shopname'] ."</a></td>";
OR
print " <td><a href='#'>".$info['shopname'] ."</a></td>";
回答2:
You are missing concatenation operators (actually you're using strings incorrectly):
Print " <td>" "<a href="#">".$info['shopname'] ."</a>" "</td> ";
should be:
Print " <td>" . "<a href=\"#\">".$info['shopname'] ."</a>". "</td> ";
or even better:
Print " <td><a href=\"#\">".$info['shopname'] ."</a></td> ";
or even more betterer:
Print ' <td><a href="#">'.$info['shopname'] .'</a></td> ';
or even more bettererer:
printf(' <td><a href="#">%s</a></td> ', $info['shopname']);
回答3:
Print " <td>" "<a href="#">".$info['shopname'] ."</a>" "</td> ";
should be
print " <td> <a href='#'>".$info['shopname'] ."</a> </td> ";
来源:https://stackoverflow.com/questions/20289720/error-when-retrieving-value-from-database-and-applying-to-anchor-tag