|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Prev - Next link tutorial.
I checked out a couple of these tutorials and decided to go with the one codewalker has.
When I use it I get an Undefined index: count in line... Also, it won't show the first record of each page. I'm using 6 records per page and it shows 45 - 41 (ORDER BY refnum DESC) when it should show 46 - 41. Any suggestions. |
|
#2
|
|||
|
|||
|
RE: Prev - Next link tutorial.
|
|
#3
|
|||||
|
|||||
|
RE: Prev - Next link tutorial.
Still the same. I guess I should provide some code incase it's a problem elsewhere.
php Code:
|
|
#4
|
|||
|
|||
|
RE: Prev - Next link tutorial.
OK, let me give this a shot.
First thing: There is no need to place parens, (), around you assignments to $query. Second: Parens are not required for echo, take those out. Third: to be consistent with the tutorial your echo statment is in the wrong place (and this is where your problem starts). //You assigned $query to this string, take out parens $query = ("SELECT * FROM dave ORDER BY refnum DESC LIMIT " . $start . ", 6"); // this is where you actually query the db $result = mysql_query($query); // then you assigned $query to this other string, take parens out $query = ("SELECT count(*) as total FROM apartment ORDER BY refnum DESC"); // here you assign $row to the result set of your _FIRST_ query $row = mysql_fetch_array($result); // now your trying to use an index value total but this index value is in your second query that you never executed $numrows = $row['total']; I hope that makes a little sense. |
|
#5
|
|||
|
|||
|
RE: Prev - Next link tutorial.
No. ;)
See my sig. :p I understand what I've got now. I don't understand why I am missing every 6th record starting with number 1. I also don't understand why I get the undefined index. Thanks though. |
|
#6
|
|||
|
|||
|
RE: Prev - Next link tutorial.
Lets work on one problem at a time, the index thing.
It is more important to understand why it is happening as opposed to me giving you the code to fix it, feed a person for life mentality. This is the logic: a) build a query string b) execute query c) create an array with data d) do something with data // lets call this, ummmmm, FIRST_QUERY. now you have part "a" done $query = ("SELECT * FROM dave ORDER BY refnum DESC LIMIT " . $start . ", 6"); // this is part "b" for FIRST_QUERY $result = mysql_query($query); // this is part "a" for SECOND_QUERY $query = ("SELECT count(*) as total FROM apartment ORDER BY refnum DESC"); // this is part "c" for FIRST_QUERY $row = mysql_fetch_array($result); // this is part "d" of SECOND_QUERY $numrows = $row['total']; // this is again part "c" for FIRST_QUERY while ($query_data = mysql_fetch_row($result)) Something is missing, right? |
|
#7
|
|||||
|
|||||
|
RE: Prev - Next link tutorial.
Try this:
php Code:
It should get you started, _study_ it. |