September 23, 2018

How to draw different type of pyramid in PHP using short code?



To draw a simple pyramid:
Example:

<pre>
<?php
 $no = $i = 5;
 while ($i--)
    echo str_repeat(' ', $i).str_repeat('*', $no - $i)."\n";
?>
</pre>

Output:

    *
   **
  ***
 ****
*****

Note: If you want display in middle like below

    *
   * *
  * * *
 * * * *
* * * * *

- You need just give space after start in while loop in ablove example like:
Example:
<pre>
<?php
 $no = $i = 5;
 while ($i--)
    echo str_repeat(' ', $i).str_repeat('* ', $no - $i)."\n";
?>
</pre>


- The next example for display below pyramid:
Example:

<?php
$num=1;
for($i=1;$i<5;$i++){
   for($j=1;$j<=$i;$j++){
       echo $num;
       $num=$num+1;
   }
   echo "<br />";
}
?>

Output:
1
23
456
78910

September 8, 2018

HTML5 elements for media content!



Below are list of all new HTML5 elements for media content.

<audio>
      - Ites define sound content. Its (<audio>) used to add audio content to a Web Page.
Syntax  - <audio src="define path" type="auto/mpeg" ></audio>

<video>
      - Video eletemt is same basic syntax of audio element. Its also used to add video content to a Web Page.
Syntax  - <video src="define path" type="video/mp4" ></video>

<embed>
    - Its can be define container for non - HTML application

<source>
      - Used for multiple media resources for media elements like <audio> and <video>
Syntax  - <source controls>
<video src="define path" type="video/mp4" ></video>
        </source>
<track>
        - Track eletemt used as a child for <audio> and <video> element
Syntax - <video controls>
<track kind="subtitle" src="" srclang="en" label="English">
        </video>

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!

The Future of Technology: Emerging Trends to Watch in 2025

Introduction As we navigate through 2025, the technological landscape continues to evolve at an unprecedented pace. Innovations that once se...