-Karl- Posted March 19, 2010 Share Posted March 19, 2010 $con = mysql_connect("localhost","****","*****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("*****", $con); // second query for that id $query = "SELECT `title`,`news`,`postedby`,`datetime` FROM `news` WHERE `id`=`id` ORDER BY id DESC"; $run = mysql_query($query); if($run){ while($arr = mysql_fetch_assoc($run)){ echo <<<HTML <div><b><font size="2" color="#FFFFFF">{$arr['title']}</font></b><br/> <div><font size="2" color="#FFFFFF">{$arr['news']}</font></div> <div><font size="1" color="#FFFFFF"><div>Posted by</font> <font size="1" color="#3d75a7">{$arr['postedby']}</font> <font size="1" color="#FFFFFF">on</font><font size="1" color="#3d75a7"> HTML; echo date('d/m/Y \a\t H:i \G\M\T',strtotime($arr[datetime])); Okay, I have my code (see above). It's very basic, just lists the items which are found in the specific table. However, I want to be able to change this to have pages, limiting them to 15 news posts a page. But I'm not quite sure how I'd go about doing this as I'm fairly new to MySQL. So what I want is [1] [2] [3], each would link to a different page of news, depending on the LIMIT from the database. If someone could help me, or show me a tutorial it would be greatly appreciated. Thanks ~Karl Quote Link to comment https://forums.phpfreaks.com/topic/195808-php-news-numbered-link-pages/ Share on other sites More sharing options...
True`Logic Posted March 19, 2010 Share Posted March 19, 2010 You should look into "Offset" and "limit" for the mysql_query functions. If you would like examples, we can give you a few. Quote Link to comment https://forums.phpfreaks.com/topic/195808-php-news-numbered-link-pages/#findComment-1028638 Share on other sites More sharing options...
-Karl- Posted March 19, 2010 Author Share Posted March 19, 2010 I've now managed to do this, thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/195808-php-news-numbered-link-pages/#findComment-1028644 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.