WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-21-2008, 05:25 PM
WebProWorld Member
 

Join Date: Sep 2005
Location: USWebCity.com
Posts: 38
ee222 RepRank -1
Lightbulb Help -- SELECT Function PHP Script

Hello,

I have a web page which people can post their messages on it. The messages show on the page are from the old time to the recent time. You can select the pages from page 1 to the last page.

My question is how to change the messages order, so the message "page 1" show the most recent messages first instead the old messages. For example, the recent messages are in the page 1, then page 2...

Here is the web address URL: Wish Web Site .
And here is part ot the SELECT function in PHP script. Could you please tell me how to change(rewrite) the functions? Thank you.

<SELECT NAME="page" style="font-size: 7pt ;font-family: Verdana; background:#808080 url(''); color:#ececec"
onChange="ace.submit();" STYLE="BACKGROUND:#808080;COLOR:#ececec"> <?
if($wishnum%$show_num==0)
$zpage=(int)($wishnum/$show_num);
else
$zpage=(int)($wishnum/$show_num)+1;
for($i=1;$i<=$zpage;$i++){
if($page!=$i){
echo"<option value=$i>page $i</option>";
}
else{
echo"<option value=$i selected>page $i</option>";
}
}
?></SELECT>

...
__________________
Make A New Website --- USWebCity.com
>> Web Hosting Ratings and Reviews <<
Reply With Quote
  #2 (permalink)  
Old 07-11-2008, 05:00 PM
WebProWorld New Member
 

Join Date: Oct 2005
Posts: 18
wdillsmith RepRank 0
Default Re: Help -- SELECT Function PHP Script

Where are the messages being stored? If they are in a database, you can just do a "SORT BY date DESC"
__________________
Looking for a unique gift? Send one of our gourmet cookie bouquets today.
Food lovers - visit the Gourmet Gift of the Day Blog for delicious ideas.
Reply With Quote
  #3 (permalink)  
Old 07-11-2008, 05:32 PM
WebProWorld Member
 

Join Date: Sep 2005
Location: USWebCity.com
Posts: 38
ee222 RepRank -1
Lightbulb Re: Help -- SELECT Function PHP Script

It doesn't have a database or SQL. All the messages are store in one directory only.
__________________
Make A New Website --- USWebCity.com
>> Web Hosting Ratings and Reviews <<

Last edited by ee222 : 07-11-2008 at 05:38 PM.
Reply With Quote
  #4 (permalink)  
Old 07-12-2008, 10:57 AM
DaveSawers's Avatar
WebProWorld Veteran
 

Join Date: Dec 2006
Location: Calgary, Alberta, Canada
Posts: 383
DaveSawers RepRank 1
Default Re: Help -- SELECT Function PHP Script

You can use scandir to return the names of all the files in the directory: PHP: scandir - Manual

and then for each file you can get the last modified date and time using filemtime: PHP: filemtime - Manual

Put the filenames in one array and the modified dates and times in a second array. Sort the modified times using asort: PHP: asort - Manual which keeps the indexes in the original order (or use arsort if you want them in reverse order). Then step through the sorted modified times array, pulling out the keys and use the keys to access the filenames array. The filenames will then be accessed in DTM order.
__________________
Dynamic Software Development
www.activeminds.ca
Reply With Quote
  #5 (permalink)  
Old 07-19-2008, 04:08 PM
jScott_Harris's Avatar
WebProWorld Pro
 

Join Date: Jun 2003
Location: Madisonville, Ky
Posts: 101
jScott_Harris RepRank 0
Default Re: Help -- SELECT Function PHP Script

it looks like you're already getting all the messages in an array, just reverse the array: PHP: array_reverse - Manual

you could have something in the php code like this:

if(isset($rev)):
$myarray=array_reverse($myarray);
endif;

and if $rev isn't set, it would display as it does now, but once its set, the array will come up in reverse.
__________________
J. Scott Harris
Developing the Web one site at a time | C.A.D Website Design
Reply With Quote
  #6 (permalink)  
Old 07-21-2008, 03:06 PM
WebProWorld Member
 

Join Date: Sep 2005
Location: USWebCity.com
Posts: 38
ee222 RepRank -1
Default Re: Help -- SELECT Function PHP Script

Hello J. Scott Harris,

Thank you for your help. I am not a programmer. So, could you tell me how to change and add this code to my page? Where to put this code? Thanks.

Here is part of my page code:

if(!isset($page)){
$page=1;
}
$wishnum=count($temparray);
$start=$show_num*($page-1);
?>
__________________
Make A New Website --- USWebCity.com
>> Web Hosting Ratings and Reviews <<
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Styling <ul> as <select>with CSS thindenim Graphics & Design Discussion Forum 2 06-05-2007 03:45 PM
What Kind of Script/Programming Invoved With This Function ?? tcraw1010 Graphics & Design Discussion Forum 1 05-31-2007 09:27 PM
Whom to select alex-carter Search Engine Optimization Forum 2 12-29-2006 07:02 AM
phpMyAdmin has no UPDATE, SELECT, INSERT, DELETE function Any Who Database Discussion Forum 3 01-03-2006 12:56 PM
Will 'no select text script' affect SEO? virtualtraveller Google Discussion Forum 12 12-22-2005 11:05 PM


Search Engine Optimization by vBSEO 3.2.0