BigX Posted February 1, 2008 Share Posted February 1, 2008 Hi guys, I'm totally new to this site and to the art of programming in PHP! So be warned... I'm from Holland and we're great soccer fans here and I'm making a site for a 'soccer poule' (I don't know if this is correct in English) where my friends/colleagues can join and predict results/winners of the next European Soccer Championships! I'm already quite far with the site but now I want to make a script for the index page and I don't know how! I want to write articles on the index page with all the latest news, standings of the poule etc. and I want the newest article to be displayed on top and underneath the titles/headers of all the older articles! If someone clicks on one of the older articles, that whole article must be displayed on top! I'm using PHP/mysql and I will make a table in mysql that contains Id (primary key), title, article, date!! Does anyone of you guys know how to get this to work?? Again, I'm a total n00b and I got lots of help from a friend, who is great with PHP but is on a holiday for two months, so I'm in a piccle here!! Thanks in advance if you're willing to look into this! Kind Regards, BigX Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted February 1, 2008 Share Posted February 1, 2008 Simply put.. since your using php/mysql.. I am assuming you know how to use both enough to get around with it as you say you have your site pretty well off and built minus some stuff.. If you know how to pull info from your database using php.. then your already 75% there, what you need to do is pull it the say way you are now just adding a for/while loop into the concept, and then limit your results to the last 3 or 5 or 10 entries to your database. Ordering them to list from newest to oldest.. after that its all about the cosmetics (how you want it to look on output), Which if your already getting stuff out from the DB with PHP the for/while loop will just repeat the same task over and over til x has been reached. So that said you want the story on top all that is is how you format your site.. link it accordantly to match that location of your site.. I know this sounds all gibberish.. and easier said then done.. $query="SELECT * FROM database.table LIMIT 0, 5"; //0 being latest entry, 5 being the 5th oldest.. $result=mysql_query($query) or die ("Error in query: $query. " . mysql_error()); $result_a = mysql_fetch_array( $result ); while($result_a = mysql_fetch_array( $result )) { echo $result_a['row1']. "<br />"; //... echo $result_a['row2']. "<br />"; //... echo $result_a['row3']. "<br />"; //just put your quick topic link list templating/format in this area echo $result_a['row4']. "<br />"; //... (remember to break doublequotes with a \ (example: \") echo $result_a['row5']. "<br />"; //... (when using html and other like elements) } as far as the actual display of the story.. I assume (i do that alot) that you already have a defualt story showing where you want them to be.. well change it up a bit use an if-else-then style statement if need be if $var = "" then show default else show selected.. Quote Link to comment Share on other sites More sharing options...
BigX Posted February 1, 2008 Author Share Posted February 1, 2008 Hey thanks man, I'll go to work with the tips you just gave me! I hope I'll figure it out! It all made much sense so I've faith I'll get it right! Thanks again and if I'll encouter more probs I'll come back here Greetz Quote Link to comment 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.