PDA

View Full Version : Replacing Navbar RegEx in PHP


Jaxel
07-30-2009, 03:30 PM
Okay... I have the following code being run on a $navbar...

$pagenav = construct_page_nav($pagenumber, $perpage, $commentcount['total'], "video.php?do=viewdetails&videoid=", $videoid);
$pagenav = preg_replace('/href=".+?videoid=\d+"/i', 'href="#comments" onclick="getComments(1)"', $pagenav);
$pagenav = preg_replace('/href=".+?videoid=\d+&page=(\d+)"/i', 'href="#comments" onclick="getComments($1)"', $pagenav);

However, I am having an issue... demonstrated here:
http://www.8wayrun.com/video.php?do=viewdetails&videoid=718#comments

Using the code above, which is an AJAX init, you can now change the page of the comments on the fly, without having to reload the page. If you are viewing page 1 or 2, everything works fine. However, if you view any page above page 2, the link for page 1 disappears. Is there a reason for this?

--------------- Added 1248999106 at 1248999106 ---------------

Figured it out... the dot qualifier was WAY too agressive.