RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?phpcodez.com$
RewriteRule ^(/)?$ mobile [L]
Tag Archives: PHP
Force SSL htaccess
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Force https htaccess
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Data Definition Statements
- SQL Create DB – It is used to create a database
- SQL Create Table – It is used to create a table.
- SQL Create Index – It is used to create indexes in tables
- SQL Drop – can be used to delete table,indexes and databases
- SQL Truncate – can be used to delete records in table
- SQL Alter – It is used to add, delete, or modify columns in a table.
create doc file php
<?php
header(“Content-type: application/vnd.ms-word”);
header(“Content-Disposition: attachment;Filename=test.doc”);
echo “phpcodez”;
?>
SQL ROUND()
SQL ROUND() is used to round a numeric field to the number of decimals specified.
Syntaxt
SELECT ROUND(column_name,decimals) FROM table_name
Table – Users
+—–+—–+———–+
| oid | uid | price |
+—–+—–+———–+
| 1 | 1 | 60.345645 |
| 2 | 2 | 30.45564 |
| 3 | 2 | 60.78565 |
| 4 | 1 | 70.96565 |
| 5 | 2 | 80.565645 |
| 6 | 1 | 50.57565 |
+—–+—–+———–+
Example
mysql> SELECT ROUND(price,2) as price FROM orders;
+——-+
| price |
+——-+
| 60.35 |
| 30.46 |
| 60.79 |
| 70.97 |
| 80.57 |
| 50.58 |
+——-+
6 rows in set (0.00 sec)
SQL LEN()
SQL LEN() returns the length of the value in a text field.
Syntaxt
SELECT LEN(column_name) FROM table_name
SQL MID()
SQL MID() is used to extract characters from a text field.
Syntaxt
SELECT MID(column_name,start,length) FROM table_name
Table – Users
+—–+——-+
| uid | name |
+—–+——-+
| 1 | name1 |
| 2 | name2 |
| 3 | name3 |
| 4 | name4 |
+—–+——-+
Example
mysql> SELECT MID(name,1,3) as name FROM users;
+——+
| name |
+——+
| nam |
| nam |
| nam |
| nam |
+——+
4 rows in set (0.00 sec)
mysql> SELECT MID(name,2,4) as name FROM users;
+——+
| name |
+——+
| ame1 |
| ame2 |
| ame3 |
| ame4 |
+——+
4 rows in set (0.00 sec)
SQL LCASE()
SQL LCASE() converts the value of a field to lowercase.
Syntaxt
SELECT LCASE(column_name) FROM table_name
Table – Users
+——+
| name |
+——+
| AAAA |
| BBBB |
| CCCC |
| DDDD |
| EEEE |
+——+
Example
mysql> SELECT LCASE(name) FROM users;
+————-+
| LCASE(name) |
+————-+
| aaaa |
| bbbb |
| cccc |
| dddd |
| eeee |
+————-+
5 rows in set (0.00 sec)
SQL UCASE()
SQL UCASE() converts the value of a field to uppercase.
Syntaxt
SELECT UCASE(column_name) FROM table_name
Table – Users
+—–+——+
| uid | name |
+—–+——+
| 1 | aaaa |
| 2 | bbbb |
| 3 | cccc |
| 4 | dddd |
| 5 | eeee |
+—–+——+
Example
mysql> SELECT UCASE(name) AS name FROM users;
+——+
| name |
+——+
| AAAA |
| BBBB |
| CCCC |
| DDDD |
| EEEE |
+——+
5 rows in set (0.00 sec)