displaying records

4 posts Page 1 of 1
Contributors
Post
displaying records Mark
hello

im using this to display my records in a table with pagination but it will show all the records but i want it do it only shows the records that the username put in to the database i tried this.

below shows all the records
Code: Select all
$sql = 'SELECT * FROM orders LIMIT '.$page1.', 4';
this is ment to just show the records off the person logged in but seems to get an error.
Code: Select all
$sql = 'SELECT * FROM orders  WHERE OrderBy = '$username'LIMIT '.$page1.', 4';
Post
Re: displaying records CodenStuff
Thu Apr 16, 2020 4:57 pmMark wrote:
hello

im using this to display my records in a table with pagination but it will show all the records but i want it do it only shows the records that the username put in to the database i tried this.

below shows all the records
Code: Select all
$sql = 'SELECT * FROM orders LIMIT '.$page1.', 4';
this is ment to just show the records off the person logged in but seems to get an error.
Code: Select all
$sql = 'SELECT * FROM orders  WHERE OrderBy = '$username'LIMIT '.$page1.', 4';
Maybe try:
Code: Select all
$sql = "SELECT * FROM orders WHERE OrderBy = '$username' LIMIT '.$page1.', 4";
Unsure if that will work but let me know either way.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Post
Re: displaying records CodenStuff
Also what is the error?
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Post
Re: displaying records Livengood
Might have been a small error in your code that was provided. Sometimes its a bit buggy when you try and place variables into a string. Can you try the following?

When you are using LIMIT, you are passing a number, make sure to also leave out the '.
Code: Select all
$sql = "SELECT * FROM orders WHERE OrderBy = '{$username}' LIMIT {$page1}, 4";
Code: Select all
$sql = 'SELECT * FROM orders WHERE OrderBy = '" . $username . "' LIMIT '" . $page1 . "', 4';
Image
4 posts Page 1 of 1
Return to “Help & Support”