Thread: Select help

    #1
  1. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20

    Select help


    hey guys i have a script that acts like a messaging syteme between admin and user 1 way only.

    so i wan't to put on the front page(when the user logs in)

    a message box saying the date of the newest message.

    now my select is abit coplicated..

    select from .. where $user ???

    cause i need to get the lates date of that user message?
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    i think ui got it

    SELECT *
    FROM `news`
    WHERE 'techker' = `username`
    ORDER BY `dtime` ASC
    LIMIT 1 , 30


    but if he has 2 messages in the same day it shows the both

    Comments on this post

    • bigSeth disagrees : That select as you call it is rudimentary at best.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,082
    Rep Power
    380
    so just do limit 1 (forget the,30 part as i think that says show 30 rows) and also change asc to desc as i think asc will give you previous message not the latest one
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    that should help.how would i echo justethat?


    while($row = mysql_fetch_array( $result )) {

    echo $row['dtime']

    but nothing shows?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,082
    Rep Power
    380
    try your query in mysql first do something like:

    select whatever from whatever LIMIT 1,1
  10. #6
  11. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    its works good the only thing is to echo it.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,082
    Rep Power
    380
    in that case you dont do while loop as you are only getting ONE ROW you do

    $query = "whatever"
    $r = mysql_query($query)
    $row = mysql_fetch_row($r) //mysql_fetch_row or mysql_fetch_array doesnt make much difference
    $var = $row['dtime'];
  14. #8
  15. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    $query = "whatever"
    $r = mysql_query($query)
    $row = mysql_fetch_row($r) //mysql_fetch_row or mysql_fetch_array doesnt make much difference
    $var = $row['dtime'];

    so you echo $var['dtime'];
  16. #9
  17. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    sorry about that i got it going.thx for the help.i deleted all the unnecessary stuff renamed it and included it where i needed it.works great.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,082
    Rep Power
    380
    no you just echo $var since $var has NOW got the value of whavever is in $r{dtime]..
  20. #11
  21. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    i figure it out after words when i re read your post.thx!
  22. #12
  23. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2005
    Posts
    650
    Rep Power
    20
    hey how can i link to the message?

    cause i have on the front page

    your last message was on :

    now can i make the date link?
  24. #13
  25. simpleton
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    denver.colorado.usa
    Posts
    392
    Rep Power
    235
    Are you serious? You need help making the date into a link to the message?
    PHP Code:
    <a href='your_url'>$var</a
    If this is what you needed, you need to consider a new pastime/hobby/career.
    That is all.
    10% gifted 90% puzzled

IMN logo majestic logo threadwatch logo seochat tools logo