|
|
|
|
![]() ![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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: 145 Joined: 19-February 05 From: Nakorn Chaisri, Thailand Member No.: 3,864 myCENT:56.52 |
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 | 3,129 | 30th July 2004 - 11:01 AM Last post by: Shackman |
|||
![]() |
13 | galexcd | 3,143 | 14th August 2007 - 01:25 PM Last post by: Galahad |
|||
![]() |
3 | chalawanonline | 6,269 | 2nd August 2004 - 02:34 PM Last post by: Spectre |
|||
![]() |
2 | icleric | 3,669 | 4th August 2004 - 08:48 PM Last post by: icleric |
|||
![]() |
6 | LuciferStar | 11,417 | 7th November 2004 - 12:40 PM Last post by: eldeo |
|||
![]() |
9 | shadowx | 3,229 | 12th October 2009 - 07:12 PM Last post by: manish-mohania |
|||
![]() |
7 | Raptrex | 13,188 | 27th August 2004 - 11:16 PM Last post by: Spectre |
|||
![]() |
2 | CodeName_88 | 3,472 | 5th September 2004 - 03:28 PM Last post by: serverph |
|||
![]() |
4 | NuHoaXuLa | 6,230 | 29th August 2004 - 03:12 AM Last post by: NuHoaXuLa |
|||
![]() |
11 | Triple X | 6,339 | 5th September 2004 - 02:33 AM Last post by: Triple X |
|||
![]() |
4 | Schweden | 4,967 | 8th September 2004 - 09:40 AM Last post by: Schweden |
|||
![]() |
2 | Too_Hot | 3,611 | 16th September 2004 - 05:25 PM Last post by: serverph |
|||
![]() |
2 | BoSZ | 4,240 | 17th September 2004 - 09:09 PM Last post by: BoSZ |
|||
![]() |
7 | XtremeGamer99 | 6,829 | 18th December 2008 - 10:13 PM Last post by: minimcmonkey |
|||
![]() |
8 | guangdian | 5,594 | 2nd October 2004 - 05:03 AM Last post by: football123213 |
|||
|
Open Discussion | Time is now: 8th November 2009 - 10:57 AM |
Web Hosting Powered by ComputingHost.com.