|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
going to the next row in a MySQL DB with PHP
Lets say I have table called stuff with 3 columns: Id, stuff, type.
id|Stuff |type| ------------------ 1|stuff 1| 1 | ------------------ 2|stuff 2| 2 | ------------------ 3|stuff 3| 2 | ------------------ 4|stuff 4| 1 | ------------------ 5|stuff 5| 2 | ------------------ 6|stuff 6| 1 | ------------------ now to display the whole table in reverse order all I need to do is PHP Code:
That should show "stuff 6stuff 5stuff 4stuff 3stuff 2stuff 1" But I want it to only display those that are type "1" I know tp use the "WHERE" Clause to select the type but where I am not sure of what to do is how to get it to go to teh next row. I can't use "$loopid--" because it would count id's 5, 3 & 2. SO how can I get it to go to the next row thatmeets the "WHERE" criteria and actually skip over those that need ot be skipped
__________________
CHornJr "One day I'll know what I am doing" ![]() My Blog Suanhacky Lodge #49 Rebel Squadrons |
|
#2
|
|||
|
|||
|
You are almost there.
1. Put the where clause in your SQL statement. 2. Loop through the array only printing the stuff in the "stuff" column Example: PHP Code:
In the example I used an array... same thing. Instead of a loop with foreach as I did, your loop will be a while loop: PHP Code:
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. Last edited by laidbak : June 25th, 2003 at 03:50 AM. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > going to the next row in a MySQL DB with PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|