Calculating past and future dates in PHP
A nice article on how to calculate past and future dates in PHP is available at: http://www.the-art-of-web.com/php/strtotime/
A nice article on how to calculate past and future dates in PHP is available at: http://www.the-art-of-web.com/php/strtotime/
How to get a value from a table using functions and return count: Write a simple query and pass the parameters: function somename($tablename, $colnam, $colvalue, $mode, $returncolnam) { Select $returncolnam from $tablenam where $colnam=$colval } Note: For $returncolnam you can also use array number starting from 0.
You can check domain name availability of a domain name by using following code. If you want to check multiple domains for same extension modify this code by calling function again. To check different extensions you need to specify Server Name and Matching Criteria for that extension. Pass values in $server and $nomatch [php] <?php … Read more
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
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
Following code shows directory structure for the current directory. As user types in path in text box, directory path is shown for that path. e.g. if there is a directory abc in root folder and user starts typing a then he will be shown directories and files starting with a in root folder. In this … Read more
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
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 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
mysql_insert_id — Get the ID generated in the last query Use mysql_insert_id(); More information can be found at: http://php.net/mysql_insert_id Get the ID generated in the last query