Results 1 to 3 of 3

Thread: Help again

  1. #1
    Join Date
    Feb 2004
    Posts
    455

    Default Help again

    Hello,

    I did build this querry:


    $sql = "SELECT * FROM idx_link WHERE suspended=0 and category_id=76 ORDER BY RAND() limit 1";
    $result = mysql_query($sql);
    And it works, I can display 1 random link from category # 76. How would I do it if I wanted to display 1 random link but this random link would be chosen from several categories, lets say that this 1 link would randomly chosen from category # 1 OR category # 2 OR category # 3

  2. #2
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    no expert in myswl but i think you can jsut say WHERE this OR this OR this
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  3. #3
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    Quote Originally Posted by inspireme
    ...you can jsut say WHERE this OR this OR this
    that is OK for a very small number of categories ( say, 4 or 5 ) but EXTREMELY inefficient for a large number of categories. that is what dody did with the categories and bogged everything down.

    aladdin, I'll send you some code.



    .
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

Posting Permissions

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