... mySQL PHP selecting 1 random row ...



• mySQL PHP selecting 1 random row »»


I am looking for a nice way to do the following , in PHP / mySQL
  • Select a random row from a database , with a certain dateType
  • Assign the values read out to variables
  • Database has columns, dateType, date1 , date2, date3

    PHP Code:
    = "SELECT * FROM reserved dates WHERE dateType='2'
    ORDER BY RAND()
    LIMIT 1";
    = mysql_query();
    while( = mysql_fetch_array(, MYSQL_ASSOC))
    {
    echo "Date1: <br>" .
    "Date2: <br>" .
    "Date3: <br><br>";
    }

    I was just wondering if there is a more graceful way of doing i, rather than doing a while loop there ? Plus the query is probably very slow they way I have it. Maybe I will just use this : http://www.greggdev.com/web/articles.php?id=6
     Bookmark with:            
    Source: IrishWebMasterForums | pub: 04 Aug 2008 by: paul | added: 04 Aug 2008 | cat: Coding Help | views: 30 time/s
    Related Articles...
    Leave a Comment...
    Name: *
    Email: *
    Comment: *
    Security Code: security code
    *
         Remember me:
    Categories
    Channels
    Press Release