Not getting all the links

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Below is the script i am trying to get all the links,

If I populate 20 rows and run the script, only some link names are listed,
listed links,

links.php?process=&page=2
links.php?process=&page=6



what i need is,
links.php?process=&page=1
links.php?process=&page=2
links.php?process=&page=3
links.php?process=&page=4
links.php?process=&page=5
links.php?process=&page=6


If you need any further details tell me. Looking forward for some solution

$all_url=array('http://localhost/links.php'); 
echo '<h3>All url in the site ....</h3>'; 
$max=1;//dimension of $all_url+1 
for($i=0;$i<$max;$i++) 
{ 
   $url=$all_url[$i]; 
   echo  $url ;
   echo '<br/>'; 
   getLinks($url);//function finding URL on thr page 
} 


// You can use your own script to get the links if you are using php4.
function getLinks($link) 
{ 
        $link;
        global $max; 
        global $all_url; 
        $dom = new domDocument; 

        @$dom->loadHTML(file_get_contents($link)); 

        $dom->preserveWhiteSpace = false; 
        
        $links = $dom->getElementsByTagName('a'); 
     
        foreach ($links as $tag) 
        { 
            $all_url[]=$tag->getAttribute('href');
            $max++;
        } 
}  

//links.php



$rows_per_page = 3;
      $page_num = 1;
       
      if(isset($_GET['page']))
       $page_num = $_GET['page'];
            
      $offset = ($page_num - 1) * $rows_per_page;
       
      $list_links_res = mysql_query("SELECT * FROM links_table ORDER
BY link_id DESC LIMIT $offset, $rows_per_page");
      if(mysql_num_rows($list_links_res) >0)
      {
            $main_content = "<table border='0' width='60%'
class='table_paging' align='center' cellpadding='0' cellspacing='0'>
                                <tr><th>Sl.No.</th> <th>Link</th> </tr>";
             
             $sl_no=$offset;  
             while($list_links_ret = mysql_fetch_assoc($list_links_res))
             {
                   $sl_no++;
                   $links             = $list_links_ret['links'];
                               
                   $main_content .= "<tr><td>$sl_no</td>      
<td>$links</td> </tr>";  
             }
            
              
             $query_total_page_RES = mysql_query("SELECT COUNT(*) AS
max_page FROM links_table");
             $query_total_page_RET =
mysql_fetch_assoc($query_total_page_RES);
             $total_page = $query_total_page_RET['max_page'];
           
             $max_page = ceil($total_page/$rows_per_page);
             $page_links =
getPagingNumbers("links.php?process=$process", $page_num, $max_page);
             
             $main_content .="</table>
                                <table align='center'> <tr><td>
$page_links </td></tr> </table>";
      }
      


//getPagingNumbers

function getPagingNumbers($self, $page_num, $max_page)
{
  
  if($max_page >1)
  {
      if($page_num > 1)
       {
         $page = $page_num - 1;
         
         $first = "<a href='$self&page=1'>[First]</a>";
         $prev = "<a href='$self&page=$page'>[Prev]</a>";
       }
       else
       {
         $prev = '[Prev]';
         $first = '[First]';
       }
       
       if($page_num < $max_page)
       {
         $page = $page_num + 1;
         $next = "<a href='$self&page=$page'>[Next]</a>";
         $last = "<a href='$self&page=$max_page'>[Last]</a>";
       }
       else
       {
         $next = '[Next]';
         $last = '[Last]';
       }
       
       return $content= "<div> $first $prev $next $last </div>";
    }   
}  


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux