Re: Selecting number of news items on frontpage

From: Date: Thu, 01 Mar 2001 00:30:51 +0000
Subject: Re: Selecting number of news items on frontpage
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7030@lists.php.net to get a copy of this message
Matthew, My MySQL syntax is a little rusty. But if you define tables as type "MYISAM" and implement a primary key like this "nArticleKey integer unsigned not null auto_increment primary key" you will have a steadily incrementing count on your articles, as you add them, with no intervention. You could then issue as select statement like " select * from articles limit 7 order by nArticleKey descending" (maybe it should be "top" instead of "limit", check your MySLQ syntax) and feed those to the front page. Store your lowest of the retrieved article numbers, in $lownum, then for the archive, "select * from articles where nArticleKey < $lownum descending". Wrangling the results out to the page, etc. I leave to you. Maybe you've done all of this already and I'm just wasting keystrokes? Let me know how it goes, I will go have a look at the page. Regards - Miles At 10:28 PM 2/28/01 +0000, Matthew Cothier wrote:
From: milesthompson@ns.sympatico.ca (Miles Thompson) To: webmaster@sunsetbeachuk.com,php-db@lists.php.net Subject: Re: [PHP-DB] Selecting number of news items on frontpage Date: Wed, 28 Feb 2001 17:06:07 -0400 Matthew, Do you want to be told how, or want to read an interesting article on just this, including PHP script to build your archives. It's one of the early PHP tutorials -- try a search on "php movie database". I adapted code from that for my own archive, although I run a shell script, logged in as root, to actually make the directory and copy the files. That has mostly to do with security, although it could probably be overcome by having the archive directory owned by whatever name the webserver runs as. Miles PS Ah, just found it: http://www.webreview.com/pub/2000/02/11/php/index.html That will take you to their archive. Good luck!! PPS The shell script just prompts for a directory name and creates the directory, then copies all files from the web site root into the newly created directory. A second script publishes the new files. Have fun!!!
Basically I am using PHP and MySql, is there no way of just grabbing the last 7 articles entered into the database and displaying them and then linking to a page with the rest of them (ie. All the others minus the last 7 - the ones on the front page)? What loop code would I need for this, its a friends site that I have just started : www.sunsetbeachuk.com Thats the url if it helps to take a look, as you will see the front page just grows and grows as more news is added........ _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.db (#7030) next »