and i want to output them in a table
thanks if anyone can help me i am learning php.
I am study to making a links management,which use php and mysql. I will be thanks very much if someone can recommend the source code.
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("abc", $con);
$result = mysql_query("SELECT * FROM links");
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><a href='{$row[Link]}'>{$row[Name]}</a></td>" ;
echo "</tr>";
}
?>
Your quotes are all over the place, double quotes will be used to start and stop the string if you begin with them, but also you have quotes round the <a>
tag, you can also omit the quotes round the index of an array if your inside double quotes, so you could use...
echo "<td><a href='{$row[Link]}'>{$row[Name]}</a></td>" ;
Or if you want to stick with double quotes, you need to escape the inner ones...
echo "<td><a href=\"{$row['Link']}\">{$row['Name']}</a></td>" ;
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.