Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 3 of 4 FirstFirst 1234 LastLast
Results 31 to 45 of 52
  1. #31
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Uhh, what? You don't query for "author" anywhere here, so you cannot extract it. All you have to work with is title and imagelink, nothing more, nothing less. If you want author, you'll need to query for it.
    And I wouldn't bother with list if you are already pulling from $row array.
    So what are you planning to do with "author" and "imageink"?

  2. #32
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    Sorry I had image link there I meant author.

  3. #33
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    Code:
    $sql = "SELECT title, author FROM posts1 ORDER BY id DESC LIMIT 6";
    $result = mysql_query( $sql ) or die( mysql_error() );
    while($row = mysql_fetch_assoc($result))
    {
    
         $il = $row["author"];
         $title   = $row["title"];
    }
    
    mysql_close($con);
    
    ?>
    Last edited by sherlockturtle; 07-07-2012 at 07:52 PM.

  4. #34
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Your query still does not include the author, only the title and imagelink.

  5. #35
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    Ok sorry thats what i was saying i meant author...

  6. #36
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    The code you've posted above will work as expected. Each iteration for $il and $title will have the corresponding author and title for the current record.

  7. #37
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    But it only gets the first one.

  8. #38
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    No, it fetches all of them. But if you use your variables outside of the loop it will only be the last result iterated.

  9. #39
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    So as I said how could i get an individual one?

  10. #40
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    An individual what? Record? Seek it if you don't need to iterate them all.

  11. #41
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    As i said originaly I want to get a specific collums row in this case author and then the fifth one but I DIDINT know how to IMPLEMENT it into my current code.

  12. #42
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You're not making any sense here.
    If you want the FIFTH record from a resultset, use mysql_data_seek to move the resultset pointer to the fifth row. Then call a fetch on the row to pull the record out. I demonstrated this a number of posts back.

  13. #43
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    But I said I did not know how to implement it into my code.
    Code:
    sql = "SELECT title, author FROM posts1 ORDER BY id DESC LIMIT 6";
    $result = mysql_query( $sql ) or die( mysql_error() );
    while($row = mysql_fetch_assoc($result))
    {
    
         $il = $row["author"];
         $title   = $row["title"];
    }
    
    mysql_close($con);
    
    ?>

  14. #44
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    And a copy and paste of the code I added result in. . .?

  15. #45
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    Would i do $li = mysql_data_seek($result, 4);
    $record = mysql_fetch_assoc($result); ??


 
Page 3 of 4 FirstFirst 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •