Display text files in order

Discussion in 'PHP' started by cedric813, Oct 21, 2007.

  1. #1
    Hi everyone,

    I have a web site that displays prices of hotels on it. These prices are stored in separate text files so that they can be edited and displayed (using the php "include" statement) on the web page that they are supposed to be displayed on. Right now each hotel has it's own individual page where they can advertise. However, I would like to make an additional page that lists the top 10 cheapest hotels of the day. Since the prices (contained in the text files) will change all the time, this list will change all the time. I know that I can display all the prices on one page, but how do I make it so that the prices are displayed in order from lowest to highest. Is there some type of javascript code or php code that I could use to do this? Please help. I am a relative beginner and would welcome any code or help that you can provide.

    Thanks
     
    cedric813, Oct 21, 2007 IP
  2. tamilsoft

    tamilsoft Banned

    Messages:
    1,155
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Store all the prices in an array, then use array's sort function
     
    tamilsoft, Oct 21, 2007 IP
  3. cedric813

    cedric813 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi, thanks for your response. I am very new to this stuff. Could you please stear me in the right direction. Some code or a web page would be great. thanks so much.
     
    cedric813, Oct 21, 2007 IP
  4. tamilsoft

    tamilsoft Banned

    Messages:
    1,155
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You just display the contents of that text file here.., then I will give the code
     
    tamilsoft, Oct 22, 2007 IP
  5. cedric813

    cedric813 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you for your response. There are lots of text files (one for each price that needs to be displayed. They text files change as the prices change. Each text file will only have one number in it (the price). One text file might say: 51. Another one might say: 102.95. etc. Thanks so much.
     
    cedric813, Oct 22, 2007 IP