Categories
Php

Display PDF in browser via PHP

Sometimes it is required to hide the actual PDF file name for security reason. So using a webpage you can display PDF in browser without knowing the actual URL. Example source: <?php $file = ‘path-to-pdf-file/myFile.pdf’; $filename = ‘download.pdf’; header(‘Content-type: application/pdf’); header(‘Content-Disposition: inline; filename=”‘ . $filename . ‘”‘); header(‘Content-Transfer-Encoding: binary’); header(‘Accept-Ranges: bytes’); @readfile($file); ?> Save this […]

Categories
Creative blog SEO

Page rank increasing tips

Page rank is an algorithm that is used by search engine to rank your website depending on importance of links. Various types of links are available on your website i.e. backlinks, internal links, external links, inbound links, no-follow links etc. Some tips to increase page rank: Making backlinks are easy when you are done with […]

Categories
MySQL

MySQL CASE Statement

MySQL has an alternative of IF statement i.e. MySQL CASE statement by which you can check conditional statement. Besides the IF statement in MySQL, this provides an alternative conditional statement i.e. called CASE. The MySQL CASE statement makes the programming code more readable and efficient. You can use the simple CASE statement to check the […]

Categories
Php

PHP date() and strtotime() return wrong months on 31st

On 31st of every month you will get a wrong month value while using date() or strtotime() functions. In that case you need to pass the date of the first day of the current month as a second parameter to the strtotime() function. For example: $base_month = strtotime(date(‘Y-m’,time()) . ‘-01 00:00:01’); echo date(‘Y-m’,strtotime(‘-1 months’, $base_month)); […]

Categories
MySQL

MySQL Query Functions

There are so many MySQL functions that commonly used to minimize the statements like string operation functions, date time functions, aggregate functions etc. MySQL LAST_INSERT_ID To get the last generated sequence number of the last inserted row. SELECT LAST_INSERT_ID(); MySQL CAST() To convert a value of any type into a value with a your own […]

Categories
MySQL

IF statement in MySQL stored procedures

If statement allows you to execute a set of SQL statements based on condition. If certain condition returns true then statement executes, otherwise not. Example: DELIMITER $$ CREATE PROCEDURE MyifCond() BEGIN DECLARE x  INT; SET x = 1; SET y = 1; WHILE x  <= 10 DO SET  x = x + 1; IF x […]

Categories
MySQL

Cursor in MySQL stored procedures

Cursor allows you to iterate a group of rows fetched by a query and process each row. It is read only, non-scrollable and asensitive. Declare a cursor: DECLARE <cursor_title> CURSOR FOR SELECT_statement; Open a cursor: OPEN <cursor_title>; Fetch cursor: FETCH <cursor_title> INTO variables list; Close cursor: CLOSE <cursor_title>;

Categories
MySQL

Loop in MySQL stored procedures

MySQL allows you to loop statement for executing a block repeatedly based on a condition. These are like WHILE, REPEAT and LOOP. WHILE LOOP: It checks the expression at the beginning of each iteration. Example: DELIMITER $$ CREATE PROCEDURE MyWhileLoop() BEGIN DECLARE x  INT; SET x = 1; WHILE x  <= 10 DO SET  x […]

Categories
MySQL

Listing stored procedures in MySQL

In MySQL you can list or show all stored procedures and manage more efficiently. Display source code of stored procedure: Use SHOW CREATE PROCEDURE statement to display source code of a particular stored procedure. SHOW CREATE PROCEDURE GetAllUsers; Display characteristics of stored procedure: Use SHOW PROCEDURE STATUS to list all stored procedures. SHOW PROCEDURE STATUS […]

Categories
MySQL

MySQL stored procedure parameters and variables

All the stored procedure needs parameters to make more flexible. It has one of these three modes i.e. IN, OUT or INOUT. IN: Default mode i.e. calling program has to pass an argument to the stored procedures and value of IN parameter is changed inside of stored procedure even after stored procedure ends, the values […]