How do i display content from a MySQL DB in PHP
OK, the title may be misleading, I'm a complete novice in MySQL queries via PHP
What im actually trying to do is display a specific title of a row in a link.. for instance:
<?php echo "<a href=\"$path{$row['url']}\">Link Name</a>"; ?>
url
being the row which holds the name of the link eg, link-on开发者_如何学Pythone
. So the finished link would output
<a href="path/to/the/link-one">Link name</a>
My question is how do i select a certain entry in the url
row? not just the next/previous/random entry. This may be easy but i cant find an answer. Is this possible?Will this do the trick?
SELECT url,fn FROM $dbtable WHERE url LIKE '%link-one' ORDER BY order ASC
For this you would do something like:
$sql = "SELECT * FROM table WHERE id='$id' LIMIT 1";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo '<a href="'.$row["link"].'">'.$row["name"].'</a>';
Though php isn't as useful if you don't have a db back end I recommend reading through W3School's sql tutorials, they are quiet good (and free) http://www.w3schools.com/Sql/default.asp
精彩评论