Error when retrieving value from database and applying to anchor tag.

為{幸葍}努か 提交于 2019-12-13 08:59:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!