Select Top Percent Records MSSQL, MySQL

    Returning TOP records Microsoft SQL Server – SELECT TOP 10 column FROM table My SQL – SELECT column FROM table LIMIT 10 Returning TOP PERCENT Records Microsoft SQL Server – SELECT TOP 50 PERCENT * FROM table MySQL – SELECT @percentage := ROUND(COUNT(*) * 50/100) FROM table;   PREPARE STMT FROM ‘SELECT * FROM table LIMIT ?’;  EXECUTE…

    Read More

    Determine The First Day Of Week And The First Day Of Month

    1. Determine the first day of week (Monday) To find Monday of next week, we change ‘last’ to ‘next’. To determine the distance of current day with the first day of week, we use function: <?php echo floor((strtotime (“now”)- strtotime(“last Monday”))/86400); ?> 2. Determine the first day of month <?php $day = date(‘Y-m-d’, strtotime(date(‘Y-m-01’, strtotime(“now”))));…

    Read More

    Limit Download Speed With PHP

    http://code.google.com/p/phptraining/source/browse/trunk/download_limited.php class DownloadLimited { /** * Send the local file to client with limit download rate as user view file name * * @param string $localFile file to send * @param string $userViewFileName filename client will see * @param float $downloadRate download limit speed in kb/s (ex: 50 kb/s) * @return no return */ function…

    Read More

    PHP World – The First Concepts

    Using mature PHP or a particular programming language, the first step you should remember and distinguish between the terms / concepts most basic commonly used in relation to the language itself or enforcement platform of that language. PHP also has a list of terms (simple but easy to ignore as): PHP: PHP Hypertext Preprocesser or Personal…

    Read More