Results 1 to 6 of 6

Thread: Displaying LI in php

  1. #1
    Join Date
    Jul 2012
    Posts
    198
    Thanks
    54
    Thanked 3 Times in 3 Posts

    Default Displaying LI in php

    Can any one suggest the

    php code to display 5 elements from a unlimited list selected from data base

  2. #2
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    you could try something like:
    Code:
    SELECT * from foo ORDER BY RAND() LIMIT 5
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  3. #3
    Join Date
    Jul 2012
    Posts
    198
    Thanks
    54
    Thanked 3 Times in 3 Posts

    Default

    Hi @bernie1227

    Thanks for your response. following is my query, can u help me to add the LIMIT in this query

    "SELECT table1.id, table2.name, table1.parent_id
    from table1, table2
    where table1.categories_id = table2.categories_id "

  4. #4
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    try:
    Code:
    SELECT table1.id, table2.name, table1.parent_id
    from table1, table2
     where table1.categories_id = table2.categories_id 
    ORDER BY RAND(), LIMIT 5
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  5. #5
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    sorry, thats wrong, try:
    Code:
    SELECT table1.id, table2.name, table1.parent_id
    from table1, table2 ORDER BY RAND(), LIMIT 5
     where table1.categories_id = table2.categories_id
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  6. #6
    Join Date
    Jul 2012
    Posts
    198
    Thanks
    54
    Thanked 3 Times in 3 Posts

    Default

    Hi @bernie1227

    The idea is great. But both the query is not compatible with my code. Any way your advice brings me to correct the issue.

    Thanks ....

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
  •