How to do Tree Pagination in PHP

A tree structure means nodes within nodes. By using MySQL and PHP you can read a database then fetch records recursively. By taking an example we can understand it better. There is a table Category with records for categories and sub-categories. There are 3 columns: Id, Name, Parent Id and records are: [php] 1, A, … Read more

How to do Pagination in PHP easily

Pagination in PHP is easy and you can show pagination by following code. There are 4 files (don’t go to the number of files, separate sfiles have been created so that you can easily understand the code), I could have combined it in 1 but 4 seems to be better. These are: index.php, paging.php, function.php, … Read more

Get Page Name or File Name or Extension from Page URL

If you want to know Page Name, File Name, File Extension and directory name from a URL then you can use following function for it in PHP. [php]$path_name = "abc/xyz/name.somename.txt"; $path_parts = pathinfo($path_name); echo $path_parts[‘dirname’], "n"; echo $path_parts[‘basename’], "n"; echo $path_parts[‘extension’], "n"; echo $path_parts[‘filename’], "n";[/php] For more information you can visit: http://php.net/manual/en/function.pathinfo.php You can access its … Read more

How to show only some part of Email

Often we see that Email Address on websites are not shown completely but only first few characters are shown i.e. before @ part, 1 character after @ and last few characters of email address. It is used so that user (whose email id we are displaying) can recall what email address he has used. So, … Read more

Count Number of Files in Directory and Subdirectories

Count number of files in a directory and it’s subdirectories. Use the following code to count number of files. [php] <h1>Count Number of Files in Directory and Subdirectories</h1> <?php $dirnam=dirname(__FILE__); //No Trailing Slash// function count_files($dirpath, &$count) { $directorynames = glob($dirpath.’/*’); if(!empty($directorynames)) { foreach($directorynames as $directoryname) { if(is_dir($directoryname)) { $count[‘dirs’]++; count_files($directoryname, $count); } if(is_file($directoryname)) { $count[‘files’]++; … Read more

Print Alphanumeric with atleast 1 numeric (PHP)

How to print 3 letter Alphanumeric with atleast 1 character as Numeric. <?php $alphanumeric= array(“0″,”1″,”2″,”3″,”4″,”5″,”6″,”7″,”8″,”9″,”A”,”B”,”C”,”D”,”E”,”F”,”G”,”H”,”I”,”J”,”K”,”L”,”M”,”N”,”O”,”P”,”Q”,”R”,”S”,”T”,”U”,”V”,”W”,”X”,”Y”,”Z”); for($i=0; $i<36; $i++) { for($j=0; $j<36; $j++) { for($k=0; $k<36; $k++) { if($i>=’10’ && $j>=’10’ && $k>=’10’) { } else { $newword=$alphanumeric[$i].$alphanumeric[$j].$alphanumeric[$k]; echo “$newword<br>”; } } } } ?>

Print Alphanumeric (PHP)

How to print all 3 letter long Alphanumeric words. <?php $alphanumeric= array(“0″,”1″,”2″,”3″,”4″,”5″,”6″,”7″,”8″,”9″,”A”,”B”,”C”,”D”,”E”,”F”,”G”,”H”,”I”,”J”,”K”,”L”,”M”,”N”,”O”,”P”,”Q”,”R”,”S”,”T”,”U”,”V”,”W”,”X”,”Y”,”Z”); for($i=0; $i<36; $i++) { for($j=0; $j<36; $j++) { for($k=0; $k<36; $k++) { $newword=$alphanumeric[$i].$alphanumeric[$j].$alphanumeric[$k]; echo “$newword<br>”; } } } ?>