I have created a system where a user signs up to my site, their details are entered into my users table (SQL). The user can then search for other users, via their username. They can then send a user a friend request, entered into my friendrequest table (SQL). The friend requests are then printed onto a page using echo. If there are multiple friend requests then it shows friendrequest1 friendrequest2 friendrequest3 etc. Is it possible to get only friendrequest1 printed, the user then accepts, this users name gets place into my friends table (SQL) then friendrequest2 is shown etc, just so each request is individual. So echo could do a count of how many requests there are and show one at a time? Thanks in advance!
Asked
Active
Viewed 85 times
-1
-
[what have you tried?](http://whathaveyoutried.com) – Gordon Bailey Jan 20 '13 at 16:42
-
Will try LIMIT 1 in my SQL Statement now – iphoneapplelover123 Jan 20 '13 at 16:44
2 Answers
1
In your SQL statement, consider using LIMIT 1
, as this will return only 1 request at a time.
Combined with ORDER BY
, you can get either the newest or the oldest request.

djdy
- 6,779
- 6
- 38
- 62
-
Brilliant! Thank you, will try that out. Thanks once again, will let you know how I get on – iphoneapplelover123 Jan 20 '13 at 16:44
-
+1 thank you very much, working great now, thanks once again! – iphoneapplelover123 Jan 20 '13 at 16:48
0
When you SELECT
from the friendrequest
table, you could do a LIMIT 1
at the end, and you'll only get back one result.

Dan
- 640
- 5
- 18
-
+1 thank you very much, working great now, thanks once again! – iphoneapplelover123 Jan 20 '13 at 16:49