mysql request row jumping problem

Discussion in 'PHP' started by dmanto2two, Mar 20, 2010.

  1. #1
    I feel like this should be easy but it isn't working.

    $result = mysql_query("select photo from photo where user_id = '".$user_id."' and photo = '".$photo."' ");
    $link = mysql_result($result, 1);
    i get an unable to jump row error.
    i know this query works with mysql result($result, 0);
    but it wont work with a row jump of 1. anyone know why?
    thanks for any help
     
    dmanto2two, Mar 20, 2010 IP
  2. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is "photo" set to be unique? If so, there will be only one thing with a "photo" of $photo :)
     
    Wrighty, Mar 20, 2010 IP
  3. dmanto2two

    dmanto2two Peon

    Messages:
    56
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    oh, lol. my bad. that makes all kinds of sense. uhh then what i was trying to do is select all the photos of a user order it by time desc and then select the photo one jump down from the current photo. is there a way i can select the starting point for a mysql jump. thanks for putting up with my ridiculousness.
     
    dmanto2two, Mar 20, 2010 IP
  4. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Where do you want it to start?
     
    Wrighty, Mar 21, 2010 IP
  5. dmanto2two

    dmanto2two Peon

    Messages:
    56
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i would like to to jump one photo up from the current photo name defined by $photo($photo is a 13 character id followed by a .jpg or .png or whatever) in a list of of the users photos ordered by a timestamp. thanks man
     
    dmanto2two, Mar 21, 2010 IP
  6. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Do the query again then add to the query:
    limit 1, 1

    :)
     
    Wrighty, Mar 21, 2010 IP
  7. dmanto2two

    dmanto2two Peon

    Messages:
    56
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    sorry sef no luck. though i think i might have misunderstood.
    what i tried was
    $result = mysql_query("select photo from photo where user_id = '".$user_id."' and photo = '".$photo."' limit 1, 1
    ");
    $link = mysql_result($result, 1);
    print "$link";
    same error, but there is also an error if u try mysql_result with a jump of 0. perhaps i could select * of the photos of a user put them into an array then select the one above of below the current phot?
    is there a way to select from arrays like that? thanks wrighty
     
    dmanto2two, Mar 21, 2010 IP
  8. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Remove the Photo = "...." stuff

    Then you can step through like you tried to in your original post. Oh and remove the Limit too! :)
     
    Wrighty, Mar 21, 2010 IP
  9. aadi92s

    aadi92s Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Try this

    $result = mysql_query("select photo from photo where `user_id` = '$user_id' and `photo` = '$photo' ");
    PHP:
     
    aadi92s, Mar 21, 2010 IP
  10. dmanto2two

    dmanto2two Peon

    Messages:
    56
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    So i have tried your methods and being a bumbling asstard i had no luck. so i though about this, and what i think i want to know is can i select the number of an array row by it's value. example in an array
    array(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    ) A A
    | |___________________
    |________ |
    | |
    can i return this value by selecting this
    sorry if my explination is bad =(
    anyway what all of this code is for is to select the id of the next photo when ordered by time desc. So that i can create a url with the id of the next and previous photo so that the user can browse photos.
     
    dmanto2two, Mar 23, 2010 IP