Jump to content

linking words from a mysql database


cactus

Recommended Posts

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>";
}

    ?>

Link to comment
https://forums.phpfreaks.com/topic/233266-linking-words-from-a-mysql-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.