Current location: Hot Scripts Forums » Programming Languages » PHP » Help On Page Nav.


Help On Page Nav.

Reply
  #1 (permalink)  
Old 10-04-05, 04:49 PM
tommyc325's Avatar
tommyc325 tommyc325 is offline
Wannabe Coder
 
Join Date: Sep 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Talking Help On Page Nav.

So i`m trying to create one of those page navigation ( Next Last Page 1,2,3,4,5,6,7) i`m recieving "You have an error in your SQL syntax near '0, 10' at line 1" error message.

and below is the code don`t understand whats up.

PLEASE HELP

PHP Code:

$currentPage $_SERVER["PHP_SELF"];


$maxRows_news 10;
$pageNum_news 0;
if (isset(
$_GET['pageNum_news'])) {
  
$pageNum_news $_GET['pageNum_news'];
}
$startRow_news $pageNum_news $maxRows_news;

// 03-10-01 
$today2 date('Ymd');
$spitrecords '999999999999999999999';

mysql_select_db($database_oconn$oconn);
$query_news "SELECT id, headline, content, date_format(date, '%c-%d-%y') as 'date_f' FROM news WHERE date <= $today2 ORDER by date DESC LIMIT 10, $spitrecords";
$query_limit_news sprintf("%s LIMIT %d, %d"$query_news$startRow_news$maxRows_news);
$news mysql_query($query_limit_news$oconn) or die(mysql_error());
$row_news mysql_fetch_assoc($news);

if (isset(
$_GET['totalRows_news'])) {
  
$totalRows_news $_GET['totalRows_news'];
} else {
  
$all_news mysql_query($query_news);
  
$totalRows_news mysql_num_rows($all_news);
}
$totalPages_news ceil($totalRows_news/$maxRows_news)-1;

$queryString_news "";
if (!empty(
$_SERVER['QUERY_STRING'])) {
  
$params explode("&"$_SERVER['QUERY_STRING']);
  
$newParams = array();
  foreach (
$params as $param) {
    if (
stristr($param"pageNum_news") == false && 
        
stristr($param"totalRows_news") == false) {
      
array_push($newParams$param);
    }
  }
  if (
count($newParams) != 0) {
    
$queryString_news "&" htmlentities(implode("&"$newParams));
  }
}
$queryString_news sprintf("&totalRows_news=%d%s"$totalRows_news$queryString_news); 

Last edited by tommyc325; 10-04-05 at 05:06 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-04-05, 05:22 PM
dennispopel dennispopel is offline
Coding Addict
 
Join Date: Mar 2005
Posts: 263
Thanks: 0
Thanked 0 Times in 0 Posts
Hello

$query_news = "SELECT id, headline, content, date_format(date, '%c-%d-%y') as 'date_f' FROM news WHERE date <= $today2 ORDER by date DESC ";
$query_limit_news = sprintf("%s LIMIT %d, %d", $query_news, $startRow_news, $maxRows_news);

since you duplicate the LIMIT clause
__________________
onPHP5.com - PHP5: Articles, News, Tutorials, Interviews, Software and more
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-04-05, 05:33 PM
tommyc325's Avatar
tommyc325 tommyc325 is offline
Wannabe Coder
 
Join Date: Sep 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks but.....

Thanks but i need that limit tag in my query.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classified Ads skipper23 Perl 3 11-22-05 03:22 AM
Passing a variable to another page tapir PHP 8 02-16-05 06:38 PM
need help creating an update & confirm page mikewooten PHP 1 11-08-04 05:28 PM
page browsing problem mivec PHP 3 04-17-04 04:43 AM
Classified Ads skipper23 Perl 2 12-30-03 04:43 AM


All times are GMT -5. The time now is 11:40 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.