Thursday 15 July 2010

php - How to select only 1 row from a query result? like the 4th row -



php - How to select only 1 row from a query result? like the 4th row -

i have code , looking create sort of "quotes area" on website. want select 3 random quotes database everytime. know function rand(min,max), how utilize select exact row query?

require 'db.php'; $link = mysql_connect('localhost', 'root', '430123'); $db = mysql_select_db('bakery', $link); $result = mysql_query('select * quotes');

i utilize loop , utilize mysql_fetch_row() how much number rand() was, bit inefficient maybe?

to 4th row utilize limit offset, number_of_records

select * quotes order rand() limit 3, 1

php mysql

No comments:

Post a Comment