|
|
|
|
![]() ![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED]
Posts: 936 Joined: 14-April 05 From: West Chester, PA Member No.: 5,636 |
Post
#1
Apr 14 2005, 04:04 AM
Hey everyone. It appears to me that everyone really know what they are doing in this forum and im a pretty new to this PHP and MySQL combo. I know some PHP but not MySQL....I am trying to make a new website but i want to be able to go to a certain update page and change the news on the main index. For example: - The main page show news updates of the last 10 post. - I go to the update page and then fill in the form and it will add this post to the top of the list and still only print the top 10. I have no clue how to do this with MySQL. At the moment i am doing it using a file but i know file reading is slow and annoying so i want to try to avoid it. Any help on how to do this would be wonderful or a link to website explaining it would be nice even if it points to an already written script because i can atleast study the code and write it for myself. Thanks for your help in advance |
![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 144 Joined: 19-February 05 From: Nakorn Chaisri, Thailand Member No.: 3,864 myCENT:39.35 |
Post
#2
Apr 20 2005, 07:50 AM
See MySQL responds to some cool SQL syntax and is able to fetch exactly this set of information for you. Say your table contains a couple of fields namely, a. TopicID b. TopicTitle c. Message d. PostDateTime When you insert a new topic, TopicID gets increased by 1 (or whatever increment scheme you follow) and the Time+Date of posting gets inserted into the last column. When you want to display the last 10 topics, you can use a simple statement: CODE SELECT TopicTitle FROM MyTable LIMIT 10 ORDER BY PostDateTime The LIMIT 10 will select the only 10 Topic titles from the TopicTitle column which is ORDER BY PostDateTime - i.e. ordered by date and time of post. If the order is set to descending - this will effectively pull out you last 10 entries. Try it and let me know. |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED]
Posts: 936 Joined: 14-April 05 From: West Chester, PA Member No.: 5,636 |
Post
#3
Apr 20 2005, 06:56 PM
Thanks for the response. I will try that as soon as a i get a chance and post its results. Once again thanks for the help
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 217 Joined: 2-January 05 Member No.: 3,084 |
Post
#4
Apr 24 2005, 07:11 PM
mysql tables: id,title,description CODE <? $q = mysql_query("select * from news order by id;"); while($news = mysql_fetch_array($q)){ echo "<a href=news.php?id=$news[id] target=_blank>$news[title]</a>"; } ?> news.php CODE <? $num = stripslashes($id); // security reasons $q = mysql_query("select * from news where id=$num;"); $news = mysql_fetch_array($q); ?> <?=$news[title]?><br><br> <?=$news[description]?> Try something like this, and you will just have to add your news on the database. |
![]() ![]() |
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
3 | Shackman | 384 | 30th July 2004 - 11:01 AM Last post by: Shackman |
|||
![]() |
13 | galexcd | 848 | 14th August 2007 - 01:25 PM Last post by: Galahad |
|||
![]() |
3 | chalawanonline | 361 | 2nd August 2004 - 02:34 PM Last post by: Spectre |
|||
![]() |
2 | icleric | 494 | 4th August 2004 - 08:48 PM Last post by: icleric |
|||
![]() |
6 | LuciferStar | 608 | 7th November 2004 - 12:40 PM Last post by: eldeo |
|||
![]() |
4 | shadowx | 1,010 | 23rd August 2007 - 08:23 PM Last post by: shadowx |
|||
![]() |
7 | Raptrex | 432 | 27th August 2004 - 11:16 PM Last post by: Spectre |
|||
![]() |
2 | CodeName_88 | 355 | 5th September 2004 - 03:28 PM Last post by: serverph |
|||
![]() |
4 | NuHoaXuLa | 411 | 29th August 2004 - 03:12 AM Last post by: NuHoaXuLa |
|||
![]() |
11 | Triple X | 720 | 5th September 2004 - 02:33 AM Last post by: Triple X |
|||
![]() |
4 | Schweden | 285 | 8th September 2004 - 09:40 AM Last post by: Schweden |
|||
![]() |
31 | nyy26 | 674 | 18th November 2008 - 04:34 AM Last post by: Plenoptic |
|||
![]() |
2 | Too_Hot | 305 | 16th September 2004 - 05:25 PM Last post by: serverph |
|||
![]() |
2 | BoSZ | 405 | 17th September 2004 - 09:09 PM Last post by: BoSZ |
|||
![]() |
6 | XtremeGamer99 | 268 | 10th October 2004 - 07:54 PM Last post by: moscower |
|||
|
Lo-Fi Version | Time is now: 5th December 2008 - 07:53 AM |