#1 (permalink)  
Old 11-26-2007, 11:02 PM
Registered User
 
Join Date: Jul 2004
Posts: 249
10 records per page?

How does PHP display 10 records per page?
Reply With Quote

  #2 (permalink)  
Old 11-27-2007, 02:00 PM
Registered User
 
Join Date: Jul 2004
Posts: 249
LIMIT seems to be the answer but it's not working.

Quote:
Select * FROM tablename WHERE 1=1 AND text_data LIKE '%keyword%' AND text_data LIKE '%keyword%' LIMIT 0, 10

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '1=1 AND text_data LIKE '%keyword%' AND text_data LIKE '%keyword%' LIMIT 0, 10'., SQL state 37000 in SQLExecDirect in C:\xampp\htdocs\wheelofgod\search\cat\query.php on line 262
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '1=1 AND text_data LIKE '%keyword%' AND text_data LIKE '%keyword%' LIMIT 0, 10'.
Reply With Quote
  #3 (permalink)  
Old 11-27-2007, 03:58 PM
Deadeye's Avatar
Moderator
 
Join Date: Aug 2005
Location: San Diego, CA
Posts: 274
Send a message via MSN to Deadeye
I dont know php, but why dont you query for all the results and in your while loop just iterate it 10 times?

This would work in C# and perl but I dont know about php

Wesley
__________________
Don't forget to rate me A+++++++++++++++++!!!!!111one for the service you have received.
Reply With Quote
  #4 (permalink)  
Old 11-28-2007, 04:24 PM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,445
Quote:
Originally Posted by Deadeye View Post
I dont know php, but why dont you query for all the results and in your while loop just iterate it 10 times?

This would work in C# and perl but I dont know about php

Wesley
It will work in PHP, too, but that seems like an incredible waste of resources. Imagine that you have a few million records and how many extra resources it would use to retrieve them all just to use 10 of them.

Limit is most likely the answer you're looking for, Gil, but you're using it incorrectly. Limit only accepts one parameter: the total amount of records you want returned. Therefore, rather than:
PHP Code:
Select FROM tablename WHERE 1=AND text_data LIKE '%keyword%' AND text_data LIKE '%keyword%' LIMIT 010 
it should simply be:
PHP Code:
Select FROM tablename WHERE 1=AND text_data LIKE '%keyword%' AND text_data LIKE '%keyword%' LIMIT 10 
__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote
  #5 (permalink)  
Old 11-28-2007, 04:40 PM
Registered User
 
Join Date: Jul 2004
Posts: 249
I got the following error.

Quote:
Select * FROM tablename WHERE 1=1 AND text_data LIKE '%keyword%' AND text_data LIKE '%keyword%' LIMIT 10
Quote:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '1=1 AND text_data LIKE '%keyword%' AND text_data LIKE '%keyword%' LIMIT 10'., SQL state 37000 in SQLExecDirect in C:\xampp\htdocs\wheelofgod\search\cat\query.php on line 263
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '1=1 AND text_data LIKE '%keyword%' AND text_data LIKE '%keyword%' LIMIT 10'.

Last edited by gilgalbiblewhee; 11-28-2007 at 05:22 PM.
Reply With Quote
  #6 (permalink)  
Old 11-28-2007, 05:49 PM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,445
Oh. I didn't even notice you were using Access.

Access doesn't support "Limit". Instead, you need to use a query like:
PHP Code:
Select TOP 10 FROM tablename WHERE 1=AND text_data LIKE '%keyword%' AND text_data LIKE '%keyword%' 
__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote
  #7 (permalink)  
Old 11-28-2007, 06:20 PM
Registered User
 
Join Date: Jul 2004
Posts: 249
But if I want to lay out the following pages 10 at a time then is this still good?

Last edited by gilgalbiblewhee; 11-28-2007 at 06:24 PM.
Reply With Quote
  #8 (permalink)  
Old 11-28-2007, 06:25 PM
Deadeye's Avatar
Moderator
 
Join Date: Aug 2005
Location: San Diego, CA
Posts: 274
Send a message via MSN to Deadeye
Quote:
Originally Posted by curtiss View Post
It will work in PHP, too, but that seems like an incredible waste of resources. Imagine that you have a few million records and how many extra resources it would use to retrieve them all just to use 10 of them.
I understand this, it was just a quick fix until a better solution was found.

Wesley
__________________
Don't forget to rate me A+++++++++++++++++!!!!!111one for the service you have received.
Reply With Quote
  #9 (permalink)  
Old 12-01-2007, 11:22 AM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,445
Quote:
Originally Posted by gilgalbiblewhee View Post
But if I want to lay out the following pages 10 at a time then is this still good?
It is if you have some sort of incremental ID by which you can order them. For instance, if you are using an autonumber as the primary key for the table, then you can do something like:
Code:
SELECT TOP 10 * FROM mytable WHERE myid > lastid
where "lastid" is the highest ID that you retrieved that last time you pulled the records.

For instance, the "next" and "prev" links on your third page might look something like:
Code:
<a href="mypage.php?lastid=34>Previous page</a>
<a href="mypage.php?lastid=34>Next Page</a>
Then, your SQL statements would look something like:
Code:
nextSQL = "SELECT TOP 10 * FROM mytable WHERE myid > ".$_GET['lastid']." ORDER BY myid"
prevSQL = "SELECT TOP 10 * FROM mytable WHERE myid < ".$_GET['lastid']." ORDER BY myid DESC"
__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote
  #10 (permalink)  
Old 12-01-2007, 10:13 PM
Registered User
 
Join Date: Jul 2004
Posts: 249
I don't understand how myid and lastid will be recognized. Are they defined?
Reply With Quote
  #11 (permalink)  
Old 12-01-2007, 10:47 PM
Registered User
 
Join Date: Jul 2004
Posts: 249
I don't know where I'm going wrong:
Quote:
Select TOP 10 * FROM tablename WHERE 1=1 AND text_data LIKE '%keyword%' AND text_data LIKE '%keyword%' AND id='' > lastid

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1., SQL state 07001 in SQLExecDirect in C:\xampp\htdocs\wheelofgod\search\cat\query.php on line 268
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
Reply With Quote
  #12 (permalink)  
Old 12-02-2007, 08:25 PM
Registered User
 
Join Date: Nov 2007
Posts: 2
dropship-dvd

spam elsewhere you pig.
Reply With Quote
  #13 (permalink)  
Old 12-04-2007, 08:42 PM
Registered User
 
Join Date: Jul 2004
Posts: 249
spamspamspamspamspamspamspam
Reply With Quote
  #14 (permalink)  
Old 12-18-2007, 11:17 PM
Leprakawn's Avatar
Moderator
 
Join Date: Jan 2004
Location: Outside, and playing with your invisible friends.
Posts: 1,130
Send a message via AIM to Leprakawn Send a message via Yahoo to Leprakawn
Exclamation

Nice report, whee!
__________________
Like my spiffy, unique signature?
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Code:
         ...,,.,.,.
        /          \
__oooo__[///]--[\\\]__oooo__
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Display Value (ie 28.3) dynamically in web page Bad Inferno Graphics and Flash 0 07-01-2007 06:03 AM
framespacing="0" problem solved cssiscool Programming and Scripting 4 06-14-2007 08:27 AM
go to next page function ruthann Programming and Scripting 1 08-16-2006 08:02 AM
"session validation checking" in html page ...HELP dragon Programming and Scripting 4 08-15-2006 02:06 PM
Web Template/CSS Not Sizing Full Screen on Load CouponGuy Programming and Scripting 2 06-20-2006 09:47 AM


All times are GMT -5. The time now is 12:38 PM.

 
Bitrix
Clicky Web Analytics
CloudContacts
Maxtango


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter