cactus Posted April 10, 2011 Share Posted April 10, 2011 Hi, Currently on my website I have a section where you can select an article held within a database, I still want this to happen but I wouldn't a different word to be linked to the article. Currently it reads 'Click here to view this entry' underneath the title of the article, I want he title of all the different articles to link to the right article is there anyway to do this? My code currently reads: <?php $blog_postnumber = 5; if(!isset($_GET['page'])) { $page = 1; } else { $page = (int)$_GET['page']; } $from = (($page * $blog_postnumber) - $blog_postnumber); $sql = "SELECT * FROM cms_article ORDER BY timestamp DESC LIMIT $from, $blog_postnumber"; $result = mysql_query($sql) or print ("Can't select entries from table cms_article.<br />" . $sql . "<br />" . mysql_error()); while($row = mysql_fetch_array($result)) { $date = date("l F d Y", $row['timestamp']); $title = stripslashes($row['title']); $entry = stripslashes($row['entry']); $id = $row['id']; if (strlen($entry) > 0) { $entry = substr($entry, 0, 0); $entry = "$entry<a href=\"journal.php?id=" . $id . "\">Click here to view this entry.</a>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/233266-linking-words-from-a-mysql-database/ Share on other sites More sharing options...
drisate Posted April 10, 2011 Share Posted April 10, 2011 We need more of your code because we can't see where your title is printed ... <a href=\"journal.php?id=" . $id . "\">$title</a> Quote Link to comment https://forums.phpfreaks.com/topic/233266-linking-words-from-a-mysql-database/#findComment-1199649 Share on other sites More sharing options...
cactus Posted April 10, 2011 Author Share Posted April 10, 2011 Thank you Quote Link to comment https://forums.phpfreaks.com/topic/233266-linking-words-from-a-mysql-database/#findComment-1199651 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.