Specific selection of records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • whiteyoh
    New Member
    • Jun 2008
    • 13

    Specific selection of records

    Hi,

    I have a script that can select a number of random records to display but what im after is a snippet of code on the first selection will choose a random record, but on the second selection will again choose a random record, but will discount the record that has already been picked. Basically so the same record cant be displayed twice.

    I hope that makes sense.

    What i was thinking may be a solution would be if i could select 10 random records, then choose 3 rows from that 10?!!?!?!?

    if you can, a snippet would be fantastic too.

    Many thanks
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Hi Whiteyoh

    First of all, why do you need to select 10 random records and then 3 of that. why not just get the 3 the first time?

    Second, are you using MySQL, assuming you are, here's the what query would look like:

    Code:
    SELECT * FROM your_table_name_here ORDER BY rand() LIMIT 3
    Change the 3 to 10, or whatever integer number you need.

    Let me know of any questions,


    Dan

    Comment

    • whiteyoh
      New Member
      • Jun 2008
      • 13

      #3
      right thats cool. I use that bit already. And i am using mysql

      Now lets say i have 3 seperate div tags, and each div will display 1 record, how can i say

      <div> Display record 1 </div>

      <div> Display record 2 </div>

      <div> Display record 3 </div>

      Thanks again

      Comment

      • dlite922
        Recognized Expert Top Contributor
        • Dec 2007
        • 1586

        #4
        Originally posted by whiteyoh
        right thats cool. I use that bit already. And i am using mysql

        Now lets say i have 3 seperate div tags, and each div will display 1 record, how can i say

        <div> Display record 1 </div>

        <div> Display record 2 </div>

        <div> Display record 3 </div>

        Thanks again
        You're asking me how to display MySQL results?

        Learn how to execute a MySQL query using PHP with Tizag.com's MySQL Query lesson.


        How good is your PHP?

        You print those tags by using one of the PHP looping structures and the mysql query result.

        If you still can't figure it out, post your PHP code and i'll help you.

        -Dan

        Comment

        Working...