Andrew Odendaal
Members
-
Joined
-
Last visited
Reputation Activity
-
Andrew Odendaal reacted to webdeveloper93 in My simple paginationOk so i built this simple php pagination script people can use if you find this post useful and enjoy my work please give me a +1.
<?php mysql_connect("localhost","root","") or die (mysql_error()); mysql_select_db(yourtable); $page = (!$_GET['page'] || $_GET['page'] < 0) ? "1" : $_GET['page']; $page = ceil($page); $limit = 5; $start = $limit; $end = $page*$limit-($limit); $amount = "SELECT * FROM `yourtable`"; $amount2 = mysql_query($amount) or die(mysql_error()); $amount3 = mysql_num_rows($amount2); $pages = ceil($amount3/$limit); $previous = ($page-1 <= 0) ? "« Prev" : "<a href=\"./yourpage.php?page=".($page-1)."\">« Prev</a>"; $nextpage = ($page+1 > $pages) ? "Next »" : "<a href=\"./yourpage.php?page=".($page+1)."\">Next »</a>"; echo $previous; for($i=1;$i<=$pages;$i++){ $href = ($page == $i) ? " ".$i." " : " <a href=\"./yourpage.php?page=".$i."\">".$i."</a> "; echo $href; } echo $nextpage; ?>
Hope you find it useful cheers
-
Andrew Odendaal reacted to webdeveloper93 in Doing simple BBcodeOk so imma show you how to do some simple BBcode which is very useful if i might say so myself below is how to do it.The below exapmle will cover how to do BB code for Bold,italic,And createing a smilie
<?php $BB = array(' ' => '<img src="images/happy.gif">','[b]' => '<b>','[/b]' => '</b>', '[i]' => '<i>','[/i]' => '</i>'); function bb_code( $a ){ $string = array_keys($GLOBALS['BB']); $a = str_replace($string,$GLOBALS['BB'],$a); return $a; } echo "".bb_code($string).""; ?>
And thats a simple way to create some bb code you can create a simple form to test it out hope you enjoy oh and the image path to your smilie enter your own path
If you like this please give me a +1