okay this might be hard to explain.
But i have set up a news system, and a submit page.
I know the code to get the (title, description, message/article,avatar, user and date) off the database to be displayed.
But what i want is the description to show but people will have to click on the title to get into the post. if you know what i mean.
So basicly how to url the message in the title name
cheers all
title link from sql
Started by b3nji, Jul 16 2005 07:09 AM
3 replies to this topic
#1
Posted 16 July 2005 - 07:09 AM
#2
Posted 16 July 2005 - 07:55 AM
Err.. wow. I dunno that may not even be possible. Unless it's all going to be in differant rows..which then you'd need to manually put up the links anyway. But, how's this for the linked off page.
-------------------------------------------------------------
if(isset($_POST["newsnumber"]))
{
$newsnum = $_POST["newsnumber"];
$query = mysql_query("SELECT news FROM news_table WHERE news_id = $newsnum");
mysql_connect('some_host', 'some_user', 'some_pass');
mysql_select_db('some_db');
while($news = mysql_fetch_row($query))
{
echo $news[0];
}
mysql_close();
}
----------------------------------
Pretty much
-------------------------------------------------------------
if(isset($_POST["newsnumber"]))
{
$newsnum = $_POST["newsnumber"];
$query = mysql_query("SELECT news FROM news_table WHERE news_id = $newsnum");
mysql_connect('some_host', 'some_user', 'some_pass');
mysql_select_db('some_db');
while($news = mysql_fetch_row($query))
{
echo $news[0];
}
mysql_close();
}
----------------------------------
Pretty much
Edited by MachineDog, 16 July 2005 - 07:56 AM.
#3
Posted 16 July 2005 - 08:07 AM
or this may explain it better...i could have it linked off the title or a message as 'read more'.
Take a look at my old site that uses php nuke: http://www.v8fanclub.net/
Notice that the news on the front page has a few lines then theres 'read more', thats what i want hehe, but i only learnt php recently and thats obvesly done by php nuke.
thanks all
Take a look at my old site that uses php nuke: http://www.v8fanclub.net/
Notice that the news on the front page has a few lines then theres 'read more', thats what i want hehe, but i only learnt php recently and thats obvesly done by php nuke.
thanks all
#4
Posted 16 July 2005 - 12:29 PM
To limit your text:
Then add a field to your mySQL table called something like "id" and for your "read more" link do something like this:
And create a new page to select the id from the table, and display the full message.
function limit_text($text){
$limit = 75; // Number of characters to display
if(strlen($text) > $limit){
return substr($text, 0, $limit).'...';
}
return $text;
}
Then add a field to your mySQL table called something like "id" and for your "read more" link do something like this:
echo '<a href="/read_more.php?id='.$row['id'].'>Read More</a>';
And create a new page to select the id from the table, and display the full message.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
