0

I am new in PHP and trying to get result from table between two value. I want get first row 0 to 5 numbers and so I have written query like below

$sql = "SELECT number, status, user_id 
        from number_list 
        WHERE disable=0 
        LIMIT 0,5";

But its not giving me first 5 rows. Its providing some other values. Let me know what is issue and how can I get row between two numbers ?

Thanks

1
  • I think you need to add order by clause Commented Apr 13, 2018 at 13:57

2 Answers 2

1

You should use limit 5 for first 5 rows

 $sql = "SELECT number, status, user_id from number_list WHERE disable=0 LIMIT 5 ";

anyway when the use limit should be better use order by too .. eg

 $sql = "SELECT number, status, user_id from number_list WHERE disable=0 
   order by number LIMIT 5 ";
Sign up to request clarification or add additional context in comments.

3 Comments

Add order by to Your Query: SELECT number, status, user_id from number_list WHERE disable=0 order by number LIMIT 5
@scaisEdge Thanks! its working like charm ! Thanks a lot :)
@scaisEdge I will sure do it. Thanks
0

Change LIMIT 0,5"; to LIMIT 5"; - limit takes only integers.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.