5 Replies - 885 Views - Last Post: 15 June 2015 - 01:17 PM Rate Topic: -----

#1 lk1993   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 13-June 15

create sitemap for my web site

Posted 15 June 2015 - 09:21 AM

I'm going to create sitemap to my web site.

But when I generate site maps from a generator it is create infinite URL.

In place like below it create infinite URL

subcategory.php?subid=40&page=6
In above example page number is 6. but in my site I don`t have 6 pages for this subcategory.

Also after create this it is increment page number by one a create URL again.this process is infinitely.

So why is that? How can I solve this issue?

this is the code for my pagination system.

$per_page=5;
$getcount=  mysql_query("select COUNT(*) from  adds where  subcategory='$id'") or die(mysql_error());
$fcount=  mysql_fetch_array($getcount);

$numberofpages=  ceil($fcount[0]/$per_page);


if(!isset($_GET['page'])){
$start=0;
}else{
$start=(($_GET['page']-1)*5);

}

$getadbycat=  mysql_query("select * from  adds where subcategory='$id' ORDER BY add_id DESC LIMIT $start,5 ") or die(mysql_error());


<nav class="left">
<ul class="pagination pagination-lg ">
<li>

<?php
if(!isset($_GET['page']) ||($_GET['page'])==1){

}else{
$c=$_GET['page'];
?>
<a href="http://localhost/adz/subcategory.php?subid=<?php echo $id;?>&page= <?php echo $c-1;?>" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
<?php
}
?>



</li>
<?php
$countno=1;

while($countno <= $numberofpages){
?><li><a href="http://localhost/adz/subcategory.php?subid=<?php echo $id;?>&page=<?php echo $countno;?>"><?php echo $countno;?></a></li><?php
$countno++;
}

?>


<li>

<?php
if(!isset($_GET['page'])){
$c=1;
?><a href="http://localhost/adz/subcategory.php?subid=<?php echo $id;?>&page=<?php echo $c;?>" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
<?php
}else if($_GET['page']==$numberofpages){

}

else{
$c=$_GET['page'];
?><a href="http://localhost/adz/subcategory.php?subid=<?php echo $id;?>&page=<?php echo $c+1;?>" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
<?php
}
?>


</li>
</ul>
</nav>





thank you

Is This A Good Question/Topic? 0
  • +

Replies To: create sitemap for my web site

#2 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2804
  • View blog
  • Posts: 8,152
  • Joined: 15-January 14

Re: create sitemap for my web site

Posted 15 June 2015 - 11:26 AM

Maybe the site map generator has a bug, or maybe you're printing links to pages that don't exist.
Was This Post Helpful? 0
  • +
  • -

#3 lk1993   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 13-June 15

Re: create sitemap for my web site

Posted 15 June 2015 - 11:35 AM

View PostArtificialSoldier, on 15 June 2015 - 11:26 AM, said:

Maybe the site map generator has a bug, or maybe you're printing links to pages that don't exist.


thank you for the reply.

i try to make sitemap using different generator.but same error.

i think it is because some error in my pagination system.

 <li>
        
         <?php
         if(!isset($_GET['page'])){
        $c=1;
        ?><a href="http://localhost/adz/category.php?cat_id=<?php echo $id;?>&page=<?php echo $c;?>" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
          <?php
         }else if($_GET['page']==$numberofpages){
             
         }
         
         else{
             $c=$_GET['page'];
             if($c+1 > $numberofpages){
                 
             }else{
             ?><a href="http://localhost/adz/category.php?cat_id=<?php echo $id;?>&page=<?php echo $c+1;?>" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
          <?php
             }
         }
        ?>
       
       
    </li>



in above code do i have any method to avoid that a situation like page_number > number of page?
Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2804
  • View blog
  • Posts: 8,152
  • Joined: 15-January 14

Re: create sitemap for my web site

Posted 15 June 2015 - 12:05 PM

Well, you have those empty if statements. But you can always just pull up those pages and test it out.
Was This Post Helpful? 0
  • +
  • -

#5 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3839
  • View blog
  • Posts: 14,004
  • Joined: 08-August 08

Re: create sitemap for my web site

Posted 15 June 2015 - 01:16 PM

You have a much bigger problem than your sitemap. Using mysql_query means it's just a matter of time before your site is hacked. Use prepared statements in PDO or MySQLi.
Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3839
  • View blog
  • Posts: 14,004
  • Joined: 08-August 08

Re: create sitemap for my web site

Posted 15 June 2015 - 01:17 PM

Deprecated MySQL functions are simpler to use (not counting all the sanitizing you need to add) than PDO or MySQLi prepared statements, but far less secure. That's why they've been deprecated. If you're just learning PHP you should start with
http://www.dreaminco...duction-to-pdo/
or
http://php.net/manua...-statements.php
When dealing with old code that uses deprecated MySQL functions you should replace them if possible. If it's not possible, your experience with PDO or MySQLi will benefit you when dealing with MySQL functions.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1