SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: while
-
Dec 24, 2002, 02:08 #1
-
Dec 24, 2002, 02:25 #2
- Join Date
- Jan 2002
- Location
- Israel
- Posts
- 57
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
mmm...
if the next code is exactly after this one all there is to do is to copy the exact loop. since the value of $i is 10 the next time this loop will occure its value will be increased by one. one you should change is the limit of the loop to be $i <= 20
this is one way.
if the 10-20 loop is not right after this loop then u can assign the value of 10 to the $i varible.
what i would have done in a situation like this is a bit different. first of all i'd use a for loop instead of while loop. then if u want to show on the first page the 1-10 results and on the next page to show the 10-20 results i'd use a varible in the link to the next page. something like: http://www.someDomain.com/results.php?StartFrom=10
then in the script itself in the "for" loop u can use the $_GET['StartFrom'] and run that loop as long as the $i varible is smaller/equall to $_GET['StartFrom']+10
that is it.
hope i was clear enough.
lots of luck
Shanor.You can't see your self in the mirror with your eyes closed!
-
Dec 24, 2002, 03:10 #3
- Join Date
- Oct 2002
- Location
- Scotland
- Posts
- 3,631
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Better still ... use the LIMIT clause in mySQL to return a specific set of records ...
PHP Code:// These values can be set dynamically, like the
// post above suggests.
$start = 0;
$limit = 10;
// Use them in a SQL command
$sql = "SELECT * FROM MyTable LIMIT $start, $limit";
$search = mysql_query ($sql);
// Loop through the records
while ($row = mysql_fetch_array($search))
{
$songs = $row['Songs'];
print $songs;
}
-
Dec 24, 2002, 07:40 #4
-
Dec 24, 2002, 07:52 #5
- Join Date
- Jan 2001
- Location
- Alkmaar, Netherlands
- Posts
- 710
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
add to your list "I have to learn SQL".
If you are developing a database application and if you do not know basics of the tool you have, then you will have lots of difficulties.
There are few resources all around here that will make you go forward lots.
MHO
-
Dec 24, 2002, 16:19 #6
- Join Date
- Sep 2002
- Location
- Sweden
- Posts
- 251
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That is so true, and i know that. Still tho this is how I learn best - attempt to do something that is beond my knowledge and bang my head aginst the wall untill it's done
Anyway here is the first version:
Lyrics database
Once again, thank you for all your help!!!
PS. I combined both SQL (LIMIT) and while() to make it work
Bookmarks