Help pulling in 'id' with "read more" link
Posted on
16th Feb 2014 07:03 pm by
admin
I'm trying to create snippets of my articles in the cms I'm creating, and then have them redirect to to a single
page entry of the article. Right now my snippets and "read more" links are dynamic and working fine, when I
click on the "read more" link it redirects to the 'single page entry' page, but it always pulls up the article
with id=1, even if the link is from id=23, and the adressbar reads articles.php?id=23.
How do I successfully pull up the corresponding id'd article?
any tips would be greatly appreciated!
Snippets:
Code: <?php
require("sources/connection.php");
$sql = "SELECT title, snippet, body_text, id FROM articles ORDER BY id DESC LIMIT 5" ;
$result = $conn->query($sql) or die(mysqli_error());
if($result){
while ($row = $result->fetch_object()){
echo "<h4>" . $row->title . "</h4>";
echo $row->snippet;
echo "</br>";
echo "<a href='/jquery/articles.php?id=" . "$row->id'";
echo ">< Read more ></a>";
}
}
?>
Articles:
Code: <?php
require("sources/connection.php");
$sql = "SELECT title, body_text, id FROM articles LIMIT 1" ;
$result = $conn->query($sql) or die(mysqli_error());
if($result){
$row = $result->fetch_object();
echo "<h4>" . $row->title . "</h4>";
echo $row->body_text;
}
?>
SQL:
Code: CREATE TABLE IF NOT EXISTS `articles` (
`id` int(20) NOT NULL AUTO_INCREMENT,
`rel_id` int(20) NOT NULL,
`title` varchar(255) NOT NULL,
`snippet` longtext NOT NULL,
`body_text` longtext NOT NULL,
`who_id` varchar(50) NOT NULL,
`timestamp` int(20) NOT NULL,
`url` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
Thanks in advance!
No comments posted yet
Your Answer:
Login to answer
241
44
Other forums
Displaying returned XML in another PHP page
I have an online payment form that will return XML given if a payment is successful or declines. I
Automatically Detect Phone Model for WAP Jar Deployment
Making a wap site is fairly simple, but I'd like to know if there's a way to make it so that the wap
Simple code help with redirects
I am trying to figure out a redirect script that detects if the browser is IE 7 and if it does, redi
Help If user voted, block them
On my Prayer request site, i let users Click a button to Pray for somone that has posted a pray, i g
Inserting multiple records from single form
I've found a number of threads that deal with this issue, but I'm new to php and coding language so
Problems generating word documents on server side for security reasons
I have a problem with word documentation generation when generating a word document (docx) with PHP.
Material xxx does not exist in plant xxx
Dear All,
I am working for a steel project which is repetitive manufacturing.
What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is goin
passing an array of objects after submit
How do I do this? This is what I have tried and it is not working.
<form method="
Newb advice
Hi all,
I'm a flash front end designer and I've taken on a project that needs some back end p