Loading...


bookmark - Php Dynamic News Updating Using Mysql changing a sites news using MySQL and PHP

Php Dynamic News Updating Using Mysql - changing a sites news using MySQL and PHP

 
 Discussion by fffanatics with 3 Replies.
 Last Update: April 24, 2005, 12:11 pm
 
bookmark - Php Dynamic News Updating Using Mysql changing a sites news using MySQL and PHP  
Quickly Post to Php Dynamic News Updating Using Mysql changing a sites news using MySQL and PHP w/o signup Share Info about Php Dynamic News Updating Using Mysql changing a sites news using MySQL and PHP using Facebook, Twitter etc. email your friend about Php Dynamic News Updating Using Mysql changing a sites news using MySQL and PHP Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

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

   Wed Apr 13, 2005    Reply         

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.

   Wed Apr 20, 2005    Reply         

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

   Wed Apr 20, 2005    Reply         


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.

   Sun Apr 24, 2005    Reply         

Quickly Post to Php Dynamic News Updating Using Mysql changing a sites news using MySQL and PHP w/o signup Share Info about Php Dynamic News Updating Using Mysql changing a sites news using MySQL and PHP using Facebook, Twitter etc. email your friend about Php Dynamic News Updating Using Mysql changing a sites news using MySQL and PHP Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Similar Topics:

Php News Script

How to make a News script with PHP + MySQL So..in this tutorial i will explain how to create PHP news script. first we have to create the table in My SQL.. with the code below you will do this ( you have to enter it into SQL field ..in PHPmyADMIN) ...more

   17-May-2005    Reply         

Php And Mysql Programming

hi everyone! I am making a program using php and mysql...I am a noob on this so i need your help guys...I want to make a simple program that will some values and then store them on a database and then retrieve them...uhmm let me give an example out put of what i need. T ...more

   05-May-2008    Reply         

Best Php And Mysql Editor For Noobs

hi there guys, from my previous posting, i am a noob in php and mysql programming. I want to know if there are any php and mysql editors which are best for me as a noob. i appreciate your kindness ...more

   06-May-2008    Reply         

Wc3 warcraft 3 scripting   Wc3 warcraft 3 scripting (1) (2) Add Links   Add Links