I need to select certain the rows from a table but need to show only just five of them.
For example
select * from table where user = $user;
but i need only top five results

Recommended Answers

All 5 Replies

Member Avatar for diafol

Look at the mysql online documentation w.r.t. LIMIT.

its not working:
$getreplies="Select * from bookmarks LIMIT 0, 5 where user_name in ('$userStr') order by date_time desc LIMIT 0, 5"; //getting replies

Member Avatar for diafol
$results = mysql_query("SELECT * FROM bookmarks WHERE user_name = '$userStr' ORDER BY date_time DESC LIMIT 5");

oh i am sorry,
i solved it
i had applied limits twice

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.