displaying records

4 posts Page 1 of 1
Contributors
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

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';
http://www.mbappz.com
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

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.
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

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.
User avatar
Livengood
Serious Programmer
Serious Programmer
Posts: 444
Joined: Tue Feb 16, 2010 6:24 am

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”