View Full Version : latest articals script
careera
10-25-2009, 01:44 PM
Hi,
Can anyone help me with getting a php/mysql script where i can have the latest 10 + articals in the main page automatically without me editing the file everytime i add an artical/news!
Would anyone be able to help me!! :confused:
fobos
10-26-2009, 07:54 PM
careera,
do you have anything for an example..code or website? i believe i can help, just need clarification. Well this might help..
This will display the database and "LIMIT 10" will only display 10 only and "ORDER BY id DESC" will order the display according to your ID in the DESC order. All this can be found at w3schools (http://www.w3schools.com/php/php_mysql_intro.asp)
<?php
$con = mysql_connect("localhost","id","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db", $con);
$result = mysql_query("SELECT * FROM table LIMIT 10 ORDER BY id DESC");
while($row = mysql_fetch_array($result))
{ // Example of rows
echo $row['FirstName'];
echo " " . $row['LastName'];
echo " " . $row['Age'];
echo "<br />";
}
mysql_close($con);
?>
careera
10-27-2009, 06:21 AM
Hi and thanks, i'm glad someone is welling to help.
To tell you the truth, i'm a beginer and I just want to know how to it because a friend asked me and I've been looking for some help but never got any.
I'll look for the code or any files that is related and post it and may be you'll be able to assist.
Thanks again.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.