Results 1 to 2 of 2

Thread: Getting 5 rows of info from a table in a mysql database..

  1. #1
    Cheeko
    Guest

    Getting 5 rows of info from a table in a mysql database..

    Ok,

    So, I want to get 5 horses and the info from a mysql table.
    I have 9 horses in the table. Im using php to write the script and I was thinking of using rand(1,9) 5 times, but it is likely i will get the same horse, maybe more than once. I have been told I can order the table randomly and use the first 5 row's id to get vars like $horse1[some_info] and $horse4[some_more_info] you understand?

    So, what I could do with is some php code putting 5 id's from this 9 horse table into an array, then finding each horses info that was selecting earlier.

    Any help please?

  2. #2
    scoutt
    Guest
    well couldn't you do a rand() one time put it in a variable then call it agian and if it matches the first variable then do it again. then so on and so on. then when you got 5 variables then just get the info from mysql.

    or

    once you get all the info from mysql then it will be in an array then just do a rand() on that. anf then do a check so you don't get the same one that was just loaded.

Posting Permissions

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



Click Here to Expand Forum to Full Width