September 20, 2017

How to display image from an undisclosed folder using PHP?



You can easly display image using another PHP file.

You can pass image name after .php file.

Instead of linking directly to the image in your web page, the <img> tag links to the proxy script, and passes the name of the image as a query string.

Example:

<img src="proxy.php?img=profile.jpg" alt="This is drawn from a hidden folder" ... />

Enjoy!

Get online rgba color codes from CSS #color code




If you want to convert your css color code online,  Then many sites are available like: https://www.hexcolortool.com/

Example

Convert this CSS code : #0f72b8 into rgba code : rgba(15, 114, 184, 0.8)

Enjoy!

May 3, 2017

Database: Select Query: Laravel simple select query with example




On Laravel, you may not always want to select all columns from a database table.

- Here I try to explain with simple example:

Example:

$users = DB::table(<tablename>)->select('field1', 'field2')->get();

- If you want to used and alias for any field name then just used - as

$users = DB::table(<tablename>)->select('field1', 'field2 as newname')->get();

- Used 'Distinct' with Laravel select query

$users = DB::table(<tablename>)->distinct()->get();

- Sometime if you want to used other expression with SQL query

$users = DB::table(<tablename>)->select(DB::raw('count(*) as cnt, field1
                     ->where('field1', '>', 1)
                     ->groupBy('field1')
                     ->get();

Enjoy!

April 26, 2017

How to start development on Laravel?



I start to learn and developer on Laravel.

Laravel 5.4 is latest version.

Introdiction:

This quickstart guide provides a basic introduction to the Laravel framework and includes content on database migrations Blade templates. This is a great starting point if you are brand new to the Laravel framework or PHP frameworks in general.

For installation you need Composer and below is command for that:

-  composer create-project laravel/laravel quickstart --prefer-dist

You are free to quick start and download into your local machine.

You just need to write below command for easy download

git clone https://github.com/laravel/quickstart-basic quickstart
cd quickstart
composer install
php artisan migrate

If you have any of suggestion then please share it on comment please.

Enjoy!

April 11, 2017

How to get table all field's value in single word/query?


- If you want to get table all field's value in single and simple SQL query then you need to write some simple word.

- Use this simple query

Example:

SELECT * FROM <tablename>

Enjoy!

February 22, 2017

How to get SQL group_concat comma separated value sort in ASC/DESC order?



- Here is simple example to explain how to get group concat comma seprated value into order by

Example :

SELECT field1,
  GROUP_CONCAT(first_name ORDER BY first_name ASC SEPARATOR ',')
  FROM tablename

Enjoy!

January 17, 2017

Wordpress admin - How add custom column in post listing table?


- If you want to add custom column in wordpress admin all post listting, then you just need to add some function on functions.php file.

- Here I try to explain with one example like if you want to add Post ID on admin post listing page.



- Example:

File: wp-content/yourtheme/functions.php

//BELOW FUNCTION FOR DISPLAY HEADER TITLE
add_filter('manage_posts_columns', 'columns_header');

function columns_header('$default') {
 $default['post_id'] = 'Post ID';
 return $default;
}


//BELOW FUNCTION FOR DISPLAY VALUE ON THAT COLUMN

add_action('manage_posts_custom_column', 'columns_content', 10, 2);

function columns_content($column_name, $post_id) {
 if($column_name == 'post_id') {
  echo $post_id;
 }
}

Enjoy!

January 7, 2017

SQL - How to get between value from current timestamp with table timestamp?



- Here I explain with simple example to get between timestamp value from database value

Example:

$starttime = '1479612462'; (timestam value)
$endtime = '1479612462'; (timestam value)

SELECT * FROM <tablename> WHERE date(from_unixtime(<tablefield>)) between '".."' AND '".."'

Enjoy!

SQL - How to check database timestamp value with current timestamp



SQL - Check database timestamp value with current timestamp

- I find a solution for check sql database timestamp value with current timestamp.

Example:

If you want to get past value from current time:

- SELECT * FROM <tablename> WHERE <fieldname> >= UNIX_TIMESTAMP(currentdate())

Enjoy!

Integrating Google reCAPTCHA v3 in HTML Form with PHP

  What is Google reCAPTCHA v3? Google reCAPTCHA is a free service that helps protect websites from spam and abuse. reCAPTCHA v3 is the lates...