0

I'm trying to get this to work but I have no idea what's wrong with it.

$sql = "SELECT * FROM $datatable ORDER BY ID ASC LIMIT $start_from,
$results_per_page WHERE STATE='$category'" ;

The following one works and just shows the entire table. But I'm running into issues when I try to use WHERE STATE=Variable

$sql = "SELECT * FROM ".$datatable." ORDER BY ID ASC LIMIT $start_from, ".$results_per_page ;
1

1 Answer 1

1

You should write "ORDER BY" after the "WHERE" part. In your case it should be something like:

$sql = "SELECT * FROM $datatable WHERE STATE='$category' ORDER BY ID ASC LIMIT $start_from, $results_per_page" ;
Sign up to request clarification or add additional context in comments.

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.