Results 1 to 6 of 6

Thread: SELECT Function PHP Script

  1. #1
    Join Date
    Jul 2008
    Location
    USA
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up 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, page 2, then page 3...

    Here is the web address URL: http://www.uswebcity.com/wish/wish.php .
    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>

    ...

    __________________
    Shopping, Music & Entertainment
    >> www.USWebCity.com <<

  2. #2
    Join Date
    Jun 2008
    Posts
    40
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    If I understand correctly, you want to keep it going from page 1 to MAX, but you want page 1 to have the newest content instead of the oldest?

    If that's so, then the issue isn't here but with your database select. What database are you using?

    With SQL, you can use something like

    SELECT (columns) FROM `(table)` ORDER BY (col to order by) (ASC/DESC)

    I'm not sure how your database is setup, but for example, when I have things with dates, I just ORDER BY `date` DESC to get the newest first.

  3. The Following User Says Thank You to Keleth For This Useful Post:

    andy8828 (07-11-2008)

  4. #3
    Join Date
    Jul 2008
    Location
    USA
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Exclamation

    It doesn't have a database or SQL. All the messages are store in one directory only.

  5. #4
    Join Date
    Jul 2008
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hey man i might be able to help you out.


    I'll need to see your current working code

  6. #5
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    I think what Keleth and dicegame are getting at is trying to figure out how the results are being grabbed. There is some type of script within your php that is saying grab "X" files from this place, and then your script to determine what option type it is gets ran.

    So if you can find where in your page the files are being grabbed, either try to figure out where the "query" is being performed on the file directory, or post the code here wrapping it inside [code][/code] tags

  7. #6
    Join Date
    Jul 2008
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Why would you not use a database for this, this would be much easier if you had a database in the backend.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •