Scripts

Vorige / volgende / paginanummering

Lees de comments goed. Je moet dus zelf ff de SQL queries goed doen want die staan ingesteld op mijn eigen tabel. Dit gaat dus over 10 reacties. Dit getal moet je wel rond houden. Dus 10, 20, 30, 40 etc. Anders gaat het mis denk ik... :/ Nog niet geprobeerd :) 10 Vind ik genoeg.

vorige-volgende-paginanummering
<?

	//-- get number total replies
	$sql = "SELECT COUNT(id) FROM $table_replies WHERE tid = '" . $_GET['id'] . "' ORDER BY id";
	$res = mysql_query($sql);
	$total_replies = mysql_result($res, 0);
	
	//-- get replies
	if (!$_GET['replies'])
	{
		$replies = "0";
		$sql = "SELECT id,fid,naam,email,msg,datum,datum_edit FROM $table_replies WHERE tid = '" . $_GET['id'] . "' ORDER BY id LIMIT 0,10";
	}
	else
		$sql = "SELECT id,fid,naam,email,msg,datum,datum_edit FROM $table_replies WHERE tid = '" . $_GET['id'] . "' ORDER BY id LIMIT " . $_GET['replies'] . ",10";
	
	$res = mysql_query($sql);

                //-- loop through reactions
                if (mysql_num_rows($res) >= 1)
                {
                      while ($row = mysql_fetch_array($res))
                      {
                          echo "toon de reacties of whatever";
                       }
	}
                else
                {
                     echo "niets gevonden";
                }

	//-- unset + set some vars
	unset($p);
	$u = 0;
	$a = 1;
	$p = 0;
	//-- loop through total reactions
	for ($i = 0; $i <= $total_replies && $total_replies > 10; $i++)
	{
		//-- check if $u is smaller then 10 and if
		//-- the page hasn't been set earlier
		if ($u < 10 && $a != $p)
		{
			$num = $p + 1;
			
			if (!$num_replies && $num_replies != "0")
				$num_replies = "0";
			else
				$num_replies = $num_replies + 10;
			
			//-- check if current page is the page which's about to get generated
			if ($num_replies == $_GET['replies'] || $num_replies == $replies)
				$pages[$p] = "<b>" . $num . "</b>";
			else
				$pages[$p] = "<a href=\"" . $_SERVER['PHP_SELF'] . "?id=" . $_GET['id'] . "&cat=" . $_GET['cat'] . "&replies=" . $num_replies . "\">" . $num . "</a>";
			$a = $p;

		}
		//-- when $u is bigger then 10
		//-- start the loop of ten posts again
		elseif ($u >= 10)
		{
			unset($u);
			$p++;
		}
		
		//-- count $u
		$u++;
	}


                //-- show navigation to skip pages
	for ($i = 0; $i < count($pages); $i++)
	{
		if ($i == 0)
			echo $pages[$i];
		else
			echo " | " . $pages[$i];
	}
?>

Reacties

0
Nog geen reacties.