Jump to content

canixs

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.canixs.net

Profile Information

  • Gender
    Not Telling

canixs's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello everyone. This is my first post of in this forum and I am sure there will be alots more on the way... [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] I am on the course of learning php and hope some day will master it like all of you here. I know nothing about programming yet have some logic mind and still have a lots to learn. I am a php newbie coder, I recently worked on paginating prev/next page link function for the search engine results using Yahoo webs services. I've been searching all over the web and weren't able to find the scripts to display the results exactly like the one Yahoo or Google have on their search engine (ex. prev 1,2,3,4,5,6,7,8,9,10 next.) I gave up searching and writing one on my own with my very little knowledge about programming. Luckily, I actually did get it working flawlessly just like the one Yahoo had, but I think my code maybe a little too long and unprofessiontal or not optimal and I am sure it's still optimizable. I hope someone here can help me optimize it, though it's working without a problem, I currently use it on my site at [a href=\"http://www.canixs.net\" target=\"_blank\"]http://www.canixs.net[/a] Thank you all in advance... The function is based on 3 given data: each page is displaying 10 results at a time $res= and estimated totalResultsavailable $start = which is first result of current page $last = last result of currently page [code] <?php // Create Yahoo/Google paginating for search results Previous/Next Page links function next_prev($res, $start, $last){ $urlprefix = '<a href="'.$_SERVER['PHP_SELF'].                                '?query='.rawurlencode($_REQUEST['query']).                                '&zip='.rawurlencode($_REQUEST['zip']).                               '&type='.rawurlencode($_REQUEST['type']).                                '&start='; $urlpostfix = '"><u>'; $urlpostfix1 = '</u> </a>'; if($start >10)     echo $urlprefix .($start-10).'">◄ Previous </a> ';              if(($last-$start) == 9) {                 if($start>50) { echo $urlprefix .($start-50). $urlpostfix .(($start-1)/10-4). $urlpostfix1;}                 if($start>40) { echo $urlprefix .($start-40). $urlpostfix .(($start-1)/10-3).  $urlpostfix1;}                                      if($start>30) { echo $urlprefix .($start-30). $urlpostfix .(($start-1)/10-2).  $urlpostfix1;}                 if($start>20) { echo $urlprefix .($start-20). $urlpostfix .(($start-1)/10-1).  $urlpostfix1;}                                 if($start>10) { echo $urlprefix .($start-10). $urlpostfix .(($start-1)/10).  $urlpostfix1;}                 if($last>1) { echo '[ ' .(($start-1)/10+1). ' ] </a>';}                 if(($last+1) < $res['totalResultsAvailable'])                         { echo $urlprefix .($last+1). $urlpostfix .(($start-1)/10+2).  $urlpostfix1;}                 if(($last+11) < $res['totalResultsAvailable'])                         { echo $urlprefix .($last+11). $urlpostfix .(($start-1)/10+3).  $urlpostfix1;}                 if(($last+21) < $res['totalResultsAvailable'])                         { echo $urlprefix .($last+21). $urlpostfix .(($start-1)/10+4).  $urlpostfix1;}                 if(($last+31) < $res['totalResultsAvailable'])                         { echo $urlprefix .($last+31). $urlpostfix .(($start-1)/10+5).  $urlpostfix1;}                                  if(($last+41) < $res['totalResultsAvailable'])                         { echo $urlprefix .($last+41). $urlpostfix .(($start-1)/10+6).  $urlpostfix1;}                 if($last<50 && $res['totalResultsAvailable']>61)                         { echo $urlprefix .($last+51). $urlpostfix .(($start-1)/10+7).  $urlpostfix1;}                                  if($last<40 && $res['totalResultsAvailable']>71)                         { echo $urlprefix .($last+61). $urlpostfix .(($start-1)/10+8).  $urlpostfix1;}                 if($last<30 && $res['totalResultsAvailable']>81)                         { echo $urlprefix .($last+71). $urlpostfix .(($start-1)/10+9).  $urlpostfix1;}                 if($last<20 && $res['totalResultsAvailable']>91)                         { echo $urlprefix .($last+81). $urlpostfix .(($start-1)/10+10).  $urlpostfix1;}          echo $urlprefix .($last+1). '"> Next ►</a>';} } ?> [/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.