|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Problem with mysql pagination of results
Well I've looked through the forums, and seach google, but cant find an answer to my problem. So I'm hoping someone can help me.
I did a tutorial for the pagination of my mysql results, and it halfway works. Here's the code: PHP Code:
When I searched, it displayed all the items in my mysql table. So I replaced PHP Code:
with: PHP Code:
Now when I search, it returns the first 10 resutls like it should, but when I click Next or any of the numbered links, I get this error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE '%%' LIMIT 10, 10' at line 1 Can someone please help me out? |
|
#2
|
||||
|
||||
|
You're not sending $type (or $search) in your query string for the "Next" link, but you're using it in your query. When you hit the "Next" link, your query's being evaluated as "SELECT * FROM music WHERE LIKE '%%' ..." This is invalid SQL. Pass these two variables in your "Next" link and this'll work. Also, consider using the $_GET array to scope your variables so you don't run into problems later (and so your code's portable to systems that don't have register_globals turned on -- if you don't know what register_globals is, do a search here; there's a sticky probably in the PHP forum explaining it all quite nicely).
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
Well, that did the trick. Thanks soooo much!. Thanks for the info on $_GET, I'll have to do that.
|
|
#4
|
|||
|
|||
|
I have same problem
Quote:
Thanks, Masami |
|
#5
|
|||
|
|||
|
Sorry it took so long for my to reply
![]() K. Change this: PHP Code:
to this: PHP Code:
|
|
#6
|
|||
|
|||
|
Registering a session variable??
I was having the same problem too... forums rock! Anyway, Now my search results don't stay when I go to another page making it impossible to search and use multiple pages (paginated). Does anyone know what to do? I heard something about registering session variables, but don't really understand how to do that. Any help would be greatly appreciated.
![]() -- Stephanie -- http://www.cheezylu.com/ |
|
#7
|
||||
|
||||
|
well, sessions is an entirely new chapter, but the short rundown is:
Start your code with session_start() (all the way at the beginning of the code). After that you can populate and read the global $_SESSION[] array to store and read session variables. For more detailed info, I suggest going to the PHP forum and start a new thread, or go to PHP.net |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Problem with mysql pagination of results |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|