Jump to content

how to fix a pagination problem Oo?


rootKID
 Share

Recommended Posts

Hello people... yet again..

 

I'm helping out a friend with he's pagination "PHP" coding, but it's a bit crazy for my taste to figure out what da heck he's done hehe :P...

 

hope you can help out where i cannot...

 

this is the code of hi's

	if(isset($_GET['kategori_ID']))					  { 			$antal2 = mysql_query("SELECT * from produkt Inner Join					  kategori On produkt.FK_kategori_ID = kategori.kategori_ID 					  WHERE kategori_ID = ".$_GET['kategori_ID']." ORDER BY produkt_navn");					  			$total_count2 = mysql_num_rows($antal2);			$page2 = 1;						if(!empty($_GET['page']))			{				$page2 = $_GET['page'];			}						$per_page2 = 4;			$current_page2 = (int)$page2;			$total_pages2 = ceil($total_count2/$per_page2);			$offset2 = ($current_page2 - 1) * $per_page2;			$next_page2 = $current_page2 + 1;			$previous_page2 = $current_page2 - 1;			$has_previous_page2 = $previous_page2 >= 1 ? true:false;			$has_next_page2 = $next_page2<=$total_pages2 ? true:false;			            $query2="Select					  produkt.produkt_ID,					  produkt.produkt_billede,						  produkt.produkt_pris,					  produkt.produkt_navn					From					  produkt Inner Join					  kategori On produkt.FK_kategori_ID = kategori.kategori_ID 					  WHERE kategori_ID = ".$_GET['kategori_ID']." ORDER BY produkt_navn ASC LIMIT $per_page2 OFFSET $offset2";					  					  			$result2 = mysql_query($query2);			$count2 = mysql_num_rows($result2);													while($row2 = mysql_fetch_array($result2))			{				                      echo "					 			<div id='varewrapper'>									<div id='vareleft'>									</div><!-- vareleft end end -->									<div id='vareright'>										<div id='varerighttop'>											".$row2['produkt_navn' ]."										</div><!-- varerighttop end -->										<div id='varerightmid'>											<img src='../IMG/produktoversigt/".$row2['produkt_billede']." Kr.'>										</div><!-- varerightmid end -->										<div id='varerightbottom'>											".$row2['produkt_pris']." Kr.										</div><!-- varerightbottom end -->																	</div><!-- vareright end -->																</div><!-- varewrapper end -->";					 					 					 			}		//echo "";	echo "<div id='paging'>";		if( $total_pages2 > 1 )		{			if($has_previous_page2)			{				echo "<a href='produkter.php?kategori_ID = ".$_GET['kategori_ID']."?page=";				echo $previous_page2;				echo "'>";				echo "</a>";			}						for($i2=1; $i2<=$total_pages2; $i2++)			{				if($i2==$page2)				{					echo "$i2";				}				else				{					echo "<a href='produkter.php?kategori_ID='".$_GET['kategori_ID']."'?page=$i2'>$i2</a>";				}								if($has_next_page2)				{					echo "<a href='produkter.php?kategori_ID = ".$_GET['kategori_ID']."?page=";					echo $next_page2;					echo "'>";					echo "</a>";				}			}		}	echo"</div>";}

the problem seems to be around the "kategori_ID" down at the end of the code "after while-loop"... but i cannot be sure about this, can some of you help out perhaps? Thanks alot if possible! :)

 

- rootKID

Link to comment
Share on other sites

well.. in the URL, we already DO have the id... cos the pagination only shows when a category has been chosen... and when we try to get the URL ID in browser, it dosen't shows anything...

 

but the fun part is that, in the bottom of code where all links are starting, you can see that he tried to make a "page" in the URL to be added.. but when my mouse is hovered over the pagination link, guess what, nothing... we only get the same URL we already have "kategori_ID".. just empty, that is why i'm kinda "what the...."

 

Have you any tips etc? Not sure how to fix this one for him myself -.-'...

 

Thanks :)

Link to comment
Share on other sites

I'm out right now with some girl... will tell him when i get home, thanks.. replying when i have something new :)

 

-rootKID

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...