lordshoa Posted January 28, 2009 Share Posted January 28, 2009 OK I was wondering if some one could help out a little if this is even possible with xml. What I want to do is break the rss feed up and pagination it I have it almost working at the moment but the linkswork on page 1 but not on any other. If I choose the pages manualy I get the correct results if I put a space between page number # and the &. example: domain.com/myrssfeed1.php?currentpage=1&owner=100001 domain.com/myrssfeed1.php?currentpage=2%20&owner=100001 But with out the page links at the bottom no one will know about the other results for the other pages. I used the pagination tutorial php for this page. Can anyone see why the links are not showing up ? <? define ('IN_SITE', 1); if (!$manual_cron || IN_SITE == 1) { include_once ('includes/global.php'); $parent_dir = ''; } else { $parent_dir = ''; } header("Content-type: application/xml\n"); ini_set('max_execution_time',0); // No more timeouts ignore_user_abort(1); // No more timeouts ### SQL Functions for Data function myrssunhtmlspecialchars ($string) { $string = str_replace (''', '\'', $string); $string = str_replace ('%23', '\"', $string); $string = str_replace ('"', '\"', $string); $string = str_replace ('<', '<', $string); $string = str_replace ('>', '>', $string); $string = str_replace ('&', '&', $string); $string = str_replace (' ', ' ', $string); $string = stripslashes($string); return $string; } function myrssclean_string ($string, $maxchars=16500) { $space = array(" ","<br>","<BR>","<br/>","<br />","\r\n","\r","\n","\t","\v"); $tags = array("applet","meta","xml","blink","link","style","script","embed","object","iframe","frame","frameset","ilayer","layer","bgsound","title","base"); $string = myrssunhtmlspecialchars($string); $string = str_replace($space, ' ', $string); $string = str_replace("&039;", ' ', $string); foreach ($tags as $tag) { $string = preg_replace("@<".$tag."[^>]*?>.*?</".$tag.">@si", "", $string); } $string = preg_replace('#[\x00-\x1F\"\']#i',"",$string); $string = preg_replace('#[\x7F-\xFF\"\']#i',"",$string); $string = strip_tags($string); $string = stripslashes($string); $string = ereg_replace("[^[:blank:][:alnum:]\+,;.!:$%&@?/)(_-]", " ", $string); $string = preg_replace('/\s+/'," ",$string); $string = trim($string); $words = explode(" ",$string); $string = array(); $single_chars = array("+",",",";",".","!",":","$","%","&","@","?","/",")","(","_","-"); foreach ($words as $word) { foreach ($single_chars as $single_char) { $pattern = "/\\".$single_char."+/"; $word = preg_replace("$pattern",$single_char,$word); } if (strlen($word)==1 && !preg_match('/^[aAiIxX\+\-]/',$word)) continue; $string[]=$word; } $string = implode(" ",$string); // array to string $maxchars = (strlen($string)>$maxchars) ? $maxchars : strlen($string); $string = substr($string,0,$maxchars); $string = implode(" ",explode(" ",$string,str_word_count($string)-1)); return $string; } function getSqlNumber($sqlQuery) { $query=@mysql_query($sqlQuery); $result=@mysql_num_rows($query); @mysql_free_result($query); return $result; } function getSqlRow($query) { $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); mysql_free_result($result); return $row; } function getSqlField($sqlQuery,$field) { $isQuery = getSqlNumber($sqlQuery); $query = @mysql_query($sqlQuery) or die (mysql_error()."<br>INVALID QUERY: ".$sqlQuery); if ($isQuery>0) { $result=@mysql_result($query,0,$field); } else $result="n/a"; @mysql_free_result($query); return $result; } function main_category($category_id) { (int) $result = 0; if ($category_id > 0) { $main_category = $category_id; while ($main_category > 0) { $result = $main_category; $main_category = getSqlField("SELECT name FROM " . DB_PREFIX . "categories WHERE category_id='" . $main_category . "'", 'name'); } } return $main_category; } ### Data Cleaning Functions function remSpecialChars($string) { $string = stripslashes($string); $string = eregi_replace("'","'",$string); $string = eregi_replace('"','"',$string); return $string; } function addSpecialChars($string, $noQuotes = FALSE) { $string = eregi_replace("&","&",$string); if (!$noQuotes) $string = eregi_replace("'","'",$string); $string = eregi_replace('"','"',$string); $string = eregi_replace('<','<',$string); $string = eregi_replace('>','>',$string); $string = eregi_replace(' ',' ',$string); return $string; } ### Category Function function get_path($node) { global $db; $path = array(); $row = $db->get_sql_row("SELECT parent_id,name FROM " . DB_PREFIX . "categories WHERE category_id='".$node."'"); if ($row['parent_id']>0) { $path[] = $row['name']; $path = array_merge(get_path($row['parent_id']), $path); } return $path; } ########################## function end ######################################## ### Definitions $m1 = $_REQUEST['owner']; if($_SESSION['owner'] = NULL) { $_SESSION['owner'] = $_GET['owner_id']; }else{ $_SESSION['owner'] = $m1; } #echo 'session name:'.$_SESSION['owner'].'<BR><BR>'; $sql = ("SELECT count(*) FROM " . DB_PREFIX . "auctions WHERE active=1 and closed=0 AND deleted!=1 AND owner_id=".$_GET['owner'].""); $result = mysql_query($sql) or die("SQL 0"); $r = (mysql_fetch_row($result)); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 10; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; ### Definitions # $m1 = $_REQUEST['owner']; $isvaliduser = getSqlNumber("SELECT user_id FROM " . DB_PREFIX . "users WHERE user_id='".$_GET['owner']."'"); if (!$isvaliduser) { echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n"; echo "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n"; echo "<channel>\n"; echo "<atom:link href=\"".$setts['site_path']."myrssfeed1.php?currentpage=1&owner=".$_GET['owner']."\" rel=\"self\" type=\"application/rss+xml\"/>"; echo "<title><![CDATA[".addSpecialChars($setts['sitename'])."]]></title>\n"; echo "<link>".$setts['site_path']."</link>\n"; echo "<description><![CDATA[".addSpecialChars($setts['sitename'])."]]></description>\n"; echo "<image>\n"; echo "<url>".$setts['site_path']."images/logo.gif</url>\n"; echo "<title>".$setts['sitename']."</title>\n"; echo "<link>".$setts['site_path']."</link>\n"; echo "</image>\n"; echo "<language>en-us</language>\n"; echo "<copyright><![CDATA[Copyright (C)".date('Y')." ".$setts['sitename']." All Rights Reserved.]]></copyright>\n"; echo "</channel>\n"; echo "</rss>\n"; die(); } else { // get the info from the db $sql = "SELECT * FROM " . DB_PREFIX . "auctions WHERE owner_id='".$_GET['owner']."' ORDER BY start_time DESC LIMIT $offset, $rowsperpage"; } ### Build Feed $auctionstofeed = mysql_query("$sql"); $result = mysql_fetch_array($auctionstofeed); $storename = getSqlField("SELECT shop_name FROM " . DB_PREFIX . "users WHERE user_id='".$result['owner_id']."'","shop_name"); $storedesc = getSqlField("SELECT shop_about FROM " . DB_PREFIX . "users WHERE user_id='".$result['owner_id']."'","shop_about"); $storeimg = getSqlField("SELECT shop_logo_path FROM " . DB_PREFIX . "users WHERE user_id='".$result['owner_id']."'","shop_logo_path"); if ($result) { echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n"; echo "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n"; echo "<channel>\n"; echo "<atom:link href=\"".$setts['site_path']."myrssfeed1.php?currentpage=1&owner=".$_GET['owner']."\" rel=\"self\" type=\"application/rss+xml\"/>"; echo "<title><![CDATA[".addSpecialChars($storename)."]]></title>\n"; echo "<link>".$setts['site_path']."</link>\n"; echo "<description><![CDATA[".myrssclean_string(addSpecialChars($storedesc))."]]></description>\n"; echo "<image>\n"; echo "<url>".$setts['site_path'].$storeimg."</url>\n"; echo "<title><![CDATA[".addSpecialChars($storename)."]]></title>\n"; echo "<link>".$setts['site_path']."</link>\n"; echo "</image>\n"; echo "<language>en-us</language>\n"; echo "<copyright><![CDATA[Copyright (C)".date('Y')." ".$setts['sitename']." All Rights Reserved.]]></copyright>\n"; do { $auction_cat = get_path($result['category_id']); $auction_cata = $db->implode_array($auction_cat); $auction_cata = addSpecialChars($auction_cata); $auction_cata = main_category($result['category_id']); $photo = getSqlNumber("SELECT media_id FROM " . DB_PREFIX . "auction_media WHERE auction_id='".$result['auction_id']."'"); $user = getSqlField("SELECT username FROM " . DB_PREFIX . "users WHERE user_id='".$result['owner_id']."'","username"); $country = getSqlField("SELECT name FROM " . DB_PREFIX . "countries WHERE id='".$result['country']."'","name"); if ($photo) { $photodetails = getSqlRow("SELECT * FROM " . DB_PREFIX . "auction_media WHERE auction_id='".$result['auction_id']."' LIMIT 1"); $acer = $setts['site_path']."thumbnail.php?pic=".$photodetails['media_url']."&w=100&sq=Y&b=Y"; } else { $acer = $setts['site_path']."thumbnail.php?pic=".$setts['site_path']."images/noimg.gif&w=100&sq=Y&b=Y"; } echo "<item>\n"; echo "<pubDate>".$result['start_time']."</pubDate>\n"; echo "<guid><![CDATA[".addSpecialChars($setts[site_path]."auction_details.php?auction_id=".$result['auction_id'])."]]></guid>\n"; echo "<title><![CDATA[".addSpecialChars($result['name'])."]]></title>\n"; if ($result['buyout_price']) { echo "<description><![CDATA[<table border=\"0\" cellpadding=\"8\"><tr><td><a href=\"".addSpecialChars($setts[site_url]."auction_details.php?auction_id=".$result['auction_id'])."\"><img border=\"1\" src=\"".$acer."\" title=\"Click to view Full Size\"></a></td><td>".addSpecialChars($result['name'])." (Item: ".$result['auction_id'].")<BR>Started by Seller: ".$user." <strong>".$result['currency']." ".$result['start_price']."</strong> (".$result['nb_bids']." Bids)<br /> End Date: ".date('D, d M Y H:i:s T', $result['end_time'])."<br />Located in Country: ".$country." | Shipping Zip Code: ".$result['zip_code']." <br />Found in Category: ".$auction_cata." <br /><a href=\"".addSpecialChars($setts[site_path]."auction_details.php?auction_id=".$result['auction_id'])."\">Bid now</a> | <a href=\"".addSpecialChars($setts[site_path]."buy_out.php?auction_id=".$result['auction_id'])."\">Buy it Now</a> | <a href=\"".addSpecialChars($setts[site_path].$result[auction_id].",auction_id,item_watch,option,auction_details")."\">Add to watch list</a></td></tr></table>]]></description>\n"; } else { echo "<description><![CDATA[<table border=\"0\" cellpadding=\"8\"><tr><td><a href=\"".addSpecialChars($setts[site_url]."auction_details.php?auction_id=".$result['auction_id'])."\"><img border=\"1\" src=\"".$acer."\" title=\"Click to view Full Size\"></a></td><td>".addSpecialChars($result['name'])." (Item: ".$result['auction_id'].")<BR>Started by Seller: ".$user." <strong>".$result['currency']." ".$result['start_price']."</strong> (".$result['nb_bids']." Bids)<br /> End Date: ".date('D, d M Y H:i:s T', $result['end_time'])."<br />Located in Country: ".$country." | Shipping Zip Code: ".$result['zip_code']." <br />Found in Category: ".$auction_cata." <br /><a href=\"".addSpecialChars($setts[site_path]."auction_details.php?auction_id=".$result['auction_id'])."\">Bid now</a> | <a href=\"".addSpecialChars($setts[site_path].$result[auction_id].",auction_id,item_watch,option,auction_details")."\">Add to watch list</a></td></tr></table>]]></description>\n"; } echo "<link><![CDATA[".addSpecialChars($setts[site_path]."auction_details.php?auction_id=".$result['auction_id'])."]]></link>\n"; echo "</item>\n"; } while ($result = mysql_fetch_array($auctionstofeed)); // ****** build the pagination links ****** / // range of num links to show $range = 3; $a = $_SESSION['owner']; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo "<a href='{$_SERVER['PHP_SELF']}?currentpage=1&owner=".$a."'><<</a>"; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo "<a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage&owner=".$a."'><< /a>"; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo "[<b>$x</b>]"; // if not current page... } else { // make it a link echo "<a href='{$_SERVER['PHP_SELF']}?currentpage=$x&owner=".$a."'>$x</a>"; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo "<a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage&owner=".$a."'>></a>"; // echo forward link for lastpage echo "<a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages&owner=".$a."'>>></a>"; } // end if // ****** end build pagination links ****** / echo "</channel>\n"; echo "</rss>\n\n"; die(); } else { echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n"; echo "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n"; echo "<channel>\n"; echo "<atom:link href=\"".$setts['site_path']."myrssfeed1.php?currentpage=1&owner=".$_GET['owner']."\" rel=\"self\" type=\"application/rss+xml\"/>"; echo "<title><![CDATA[".addSpecialChars($setts['sitename'])."]]></title>\n"; echo "<link>".$setts['site_path']."</link>\n"; echo "<description><![CDATA[".addSpecialChars($setts['sitename'])."]]></description>\n"; echo "<image>\n"; echo "<url>".$setts['site_path']."images/logo.gif</url>\n"; echo "<title>".$setts['sitename']."</title>\n"; echo "<link>".$setts['site_path']."</link>\n"; echo "</image>\n"; echo "<language>en-us</language>\n"; echo "<copyright><![CDATA[Copyright (C)".date('Y')." ".$setts['sitename']." All Rights Reserved.]]></copyright>\n"; echo "</channel>\n"; echo "</rss>\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/142785-pagination-xml-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.