forgot to mention ..
its adding teh correct num of products .. just a problem with prev & next
Damn im absolutely shattered ...
less than 4 hours sleep in last 2 days
can anyone see what ive messed up here because my body and mind seems to have given up ..
Recordset NavPHP Code:$limit = 2;
mysql_select_db($dbn, $dbc);
$cquery = "SELECT count(*) from datafeed";
$cdoresult = mysql_query($cquery, $dbc);
$cresult = mysql_fetch_assoc($cdoresult);
$totalrows = mysql_num_rows($cresult);
if(empty($page)){ // Checks if the $page variable is empty (not set)
$page = 1; // If it is empty, we're on page 1
}
$limitvalue = $page * $limit - ($limit);
// Ex: (2 * 25) - 25 = 25 <- data starts at 25
$query = "SELECT * from datafeed WHERE type='Divan Bed' LIMIT $limitvalue, $limit";
$doresult = mysql_query($query, $dbc);
$result = mysql_fetch_assoc(doresult);
?>
any help appreciated.. really need my sleepPHP Code:<?php if($page != 1){
$pageprev = $page--;
echo("<a href=\"divan-beds.php?page=$pageprev\">PREV".$limit."</a> ");
}else
echo("PREV".$limit." ");
// If we're on page 1, PREV is not a link
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page++;
echo("<a href=\"divan-beds.php?page=$pagenext\">NEXT".$limit."</a>");
}else{
echo("NEXT".$limit);
}
?>
forgot to mention ..
its adding teh correct num of products .. just a problem with prev & next
also getting
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\kingsizebeds\divan-beds.php on line 8
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\kingsizebeds\divan-beds.php on line 18
PHP Code:$limit = 6;
mysql_select_db($dbn, $dbc);
$cquery = "SELECT count(*) from datafeed";
$cdoresult = mysql_query($cquery, $dbc);
$cresult = mysql_fetch_assoc($cdoresult);
LINE 8 -> $totalrows = mysql_num_rows($cresult);
if(empty($page)){ // Checks if the $page variable is empty (not set)
$page = 1; // If it is empty, we're on page 1
}
$limitvalue = $page * $limit - ($limit);
// Ex: (2 * 25) - 25 = 25 <- data starts at 25
$query = "SELECT * from datafeed WHERE type='Divan Bed' LIMIT $limitvalue, $limit";
$doresult = mysql_query($query, $dbc);
LINE 18 -> $result = mysql_fetch_assoc(doresult);
Quick scan says to me 'SELECT count' query wont return rows but the number of records in your table, or if it does perhaps this will be 1?
Also Line 18 is missing a '$' -> mysql_fetch_assoc($doresult)
fixed the $ error but still nothing..
returning products but if i set limit to 2
it will only display 2 products and teh URLs for prev & next are inactive
any one any ideas ?
and also if i add page=2 or page=3 etc to the url in teh address bar it only returns the same results as it does without $page being set
also so people know where i got this code.. it was from here
PHP Help: Pagination: Easy as PREV 1 2 3 NEXT
ive ammeded it to match my db but everything else is teh same so dont see teh problem
try adding
to the start of your code and then putting page=2, page=3 etc after your url.Code:$page=$_GET['page'];
Never argue with idiots. They just drag you down to their level and then beat you with their experience.
If ignorance is bliss then some of the people I know must be orgasmic.
did nothing ...
still same as before
can you put in a couple of lines after line 8
and see what they output.Code:echo ("Totalrows = " . $totalrows); echo ("Page = " . $page);
Never argue with idiots. They just drag you down to their level and then beat you with their experience.
If ignorance is bliss then some of the people I know must be orgasmic.
Totalrows = 1
Page =
appreciate the help . i just wanna pull my hair out at the mo
when you call the page are you putting
The ? is significant.Code:http://www.yourdomain.co.uk/thispage.php?page=2
Also can you change line 8 to say
And then see what it outputs for page and totalrowsCode:$totalrows = mysql_num_rows($cdoresult);
Never argue with idiots. They just drag you down to their level and then beat you with their experience.
If ignorance is bliss then some of the people I know must be orgasmic.
yes & line is 8 is already $cdoresult
really confusing me this one is lol
Do you want to email me the whole page to info @ findmethebestprice.co.uk so I can look at the whole code, might give me a clue whats going on.
Never argue with idiots. They just drag you down to their level and then beat you with their experience.
If ignorance is bliss then some of the people I know must be orgasmic.
ok cheers![]()
email on way now
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks