简体   繁体   中英

Display link as hyperlink enabled output from mysql in php page but I am getting error

If I execute this I am getting output properly:

echo "<a href="'.$elink.'">'.$elink.'</a>";

but when I want to display my output in a table column format I am not able to insert:

echo "<td width='200'>" <a href="'.$elink.'">'.$elink.'</a>   "</td>";
or
echo "<td width='200'>" "<a href="'.$elink.'">'.$elink.'</a>"   "</td>";
or
echo "<td width='200'>" '<a href="'.$elink.'">'.$elink.'</a>   "</td>";

请更正语法错误。

echo '<td width="200">' .  '<a href="'.$elink.'">'.$elink.'</a></td>';

Looks like you have mismatched quotes. But I would use sprintf.

echo sprintf("<td width='200'><a href='%1$s'>%1$s</a></td>", $elink);

First off you quotes are messed up. They should look like this:

echo "<td width='200'> <a href='".$elink."'>".$elink."</a></td>";

Correct your string format

echo '<td width="200"><a href="'. $elink. '">' . $elink . '</a></td>';

I suggest you to use the attribute style ( style="width:200px;" ) instead the width attribute. Remember to Url Encode the parameters contained in the href attribute.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM