This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Creating category Tree using recursion. | |
*======================================================*/ | |
function fetchCategoryTree($parent = 0, $spacing = '', $user_tree_array = array()) | |
{ | |
$sql = "SELECT `cid`, `name`, `parent` FROM `category` WHERE 1 AND `parent` = $parent ORDER BY cid ASC"; | |
$query = mysql_query($sql); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Function to generate a limited number of pagination links (First, Previous, Next and Last links included) | |
* | |
* @param integer Current page | |
* @param integer Items per page | |
* @param integer Items total | |
* @param integer Number of links to display | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* List months between two dates, the example display months of current year up to now | |
*/ | |
SELECT DATE_FORMAT(m1, '%M %Y') AS `date` | |
FROM ( | |
SELECT ('2019-09-01' - INTERVAL DAYOFMONTH('2019-11-01')-1 DAY) + INTERVAL m MONTH AS m1 | |
FROM ( | |
SELECT @rownum:=@rownum+1 AS m FROM | |
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1, | |
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* List days between two dates, the example display days of current month up to now | |
*/ | |
SELECT `date` | |
FROM ( | |
SELECT adddate('1970-01-01', t4*10000 + t3*1000 + t2*100 + t1*10 + t0) `date` | |
FROM ( | |
SELECT 0 t0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 | |
) t0, ( | |
SELECT 0 t1 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 |