SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict The Mog's Avatar
    Join Date
    Dec 2002
    Location
    Manchester UK
    Posts
    310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP/ Mysql Query ?

    Hi Guys,I am posting a link here under advisement of the PHP Guys,This is basically a MySQL Problem (We think) but it is also a PHP problemhttp://www.sitepoint.com/forums/showthread.php?t=485350Any help would be greatThanksKenny

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    i read the other thread and still don't understand your question

    perhaps you can try it again in this thread

    i do understand your table

    however, it's not at all clear what you want as a result from the query
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict The Mog's Avatar
    Join Date
    Dec 2002
    Location
    Manchester UK
    Posts
    310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK here goes......


    PHP Code:
    //run a query
    SELECT FROM table WHERE date_logged BETWEEN 1181298303 AND 1181307071 ORDER BY date_logged ASC
     
    // This will produce the following
    // ID, Date_logged
    1,  0.181181298000
    2
    ,  0.741181298060
    3
    ,  0.371181298120
    4
    ,  0.741181298180 
    5
    ,  0.371181298240
    6
    ,  0.551181298300 ---|| //this is more than 900 sec
    7,  0.921181299500 ---||
    8,  44.63,1181299560
    9
    ,  0.18,  1181299620
    10
    25.551181299780
    11
    16.111181299840
    12
    46.671181299900
    13
    4.44,  1181299960
    14
    58.701181300020
    15
    69.26,  1181300080
    16
    85.93,  1181300140
    17
    12.03,  1181300200 --|| this is more than 900 sec
    18
    46.111181301200 --||
    1931.111181301260
    20
    54.811181301320 
    OK so in the above example there are three (3) Distinct trips
    Trip 1 = Record 1 to 6
    Trip 2 = Record 7 to 17
    Trip 3 = record 18 to 20

    I would somehow like to be able to run a query and seperate the trips between two dates

    also i would like to know the start_date / end date of each trip

    I hope this is alot more clear

    Thanks

    Kenny

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    so, please show the actual results that you want the query to produce
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Addict The Mog's Avatar
    Join Date
    Dec 2002
    Location
    Manchester UK
    Posts
    310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure...

    PHP Code:
     
    <a href="page.php?start=1181298000&end=1181298300">Trip 1</a>
    <
    a href="page.php?start=1181299500&end=1181300200  ">Trip 2</a>
    <
    a href="page.php?start=1181301200&end=1181301320">Trip 3</a
    Does that make sense?

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    my advice:

    run your simple query, loop over the results with php, detect the gaps which are greater than 900, and handle accordingly

    to do this with SQL is ~way~ complex
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Addict The Mog's Avatar
    Join Date
    Dec 2002
    Location
    Manchester UK
    Posts
    310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Do you have any Idea on how to do this with PHP?

    Thanks

    K-

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by The Mog View Post
    Do you have any Idea on how to do this with PHP?
    moving thread to php forum
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •