selecting one value from the repaeted !!!

Discussion in 'PHP' started by pulikuttann, Mar 31, 2007.

  1. #1
    In my program I used to store the datas under date.But when many datas under one date comes.It fetchs and display the whole dates (repetation occurs).

    Help !!!
     
    pulikuttann, Mar 31, 2007 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,842
    Likes Received:
    4,543
    Best Answers:
    123
    Trophy Points:
    665
    #2
    So it's not a storage problem - but how you display it on the page - you don't want to repeat the date?

    Before you start create a variable called $lastDate and give it a null value. Then each row you process just compare the date with $lastDate.
    If they match don't echo/print the date.
    If they don't then echo/print the date and update the variable with the new value.
     
    sarahk, Mar 31, 2007 IP
  3. pulikuttann

    pulikuttann Banned

    Messages:
    1,839
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Not getting my friend

    !!!!
    Plz make it more clear
     
    pulikuttann, Mar 31, 2007 IP
  4. manilodisan

    manilodisan Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It would be better to share your code so others could invetigate. It's hard to presume what you're doing there :)
     
    manilodisan, Apr 1, 2007 IP
  5. pulikuttann

    pulikuttann Banned

    Messages:
    1,839
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #5
    This is the code to fetch an attribute from the database and print it in a select box !!!

    But when I select the date (since there exist same date in many rows) it is repeated many times.
     
    pulikuttann, Apr 1, 2007 IP
  6. manilodisan

    manilodisan Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well... you could create an array and use a for loop. After that use array_unique to select the data. Check the manual, try looping with data from array, learn array_unique and your app will work.
     
    manilodisan, Apr 2, 2007 IP