Posts

PHP Functions

PHP Functions If you've ever copied and pasted the same block of code more than once in your PHP project — there's a better way. It's called a function , and it's one of the most important concepts in programming. In this article, you'll learn everything about PHP functions, step by step, with real-world examples that actually make sense. What is a Function? A function is a block of code that: Has a name Can be called anytime you need it Can accept inputs (called parameters) Can return a result Think of it like a coffee machine . You put in coffee beans (input), it does its job, and gives you coffee (output). You don't need to know how it works inside — you just press the button. Why Use Functions? Without Functions                             With Functions                               Copy-paste same code everywhe...

Convert Number to Words in PHP

Convert Number to Words in PHP Introduction Sometimes, web applications need to convert numbers into words. This is commonly used in invoice systems, billing software, cheque printing, payroll applications, and financial reports. For example: 1250 becomes One Thousand Two Hundred Fifty In this tutorial, you'll learn how to convert numbers to words in PHP using a reusable function with complete source code and examples. Why Convert Numbers to Words? Converting numbers into words is useful for: Invoice generation Cheque printing Salary slips Banking applications Billing software Financial reports Lets see by real example  <?php function numberToWords($num) {     $ones = array(         0 => "zero",         1 => "one",         2 => "two",         3 => "three",         4 => "four",         5 => "five",         6 => ...

Select one checkbox at a time from group of checkbox

Select one checkbox at a time from group of checkbox <div class="btn-group" role="group" onclick="selectOne(event)">   <input type="checkbox" class="btn-check" id="btncheck1" value='1' autocomplete="off">   <label class="btn btn-outline-primary" for="btncheck1">Checkbox 1</label>   <input type="checkbox" class="btn-check" id="btncheck2" value='2' autocomplete="off">   <label class="btn btn-outline-primary" for="btncheck2">Checkbox 2</label>   <input type="checkbox" class="btn-check" id="btncheck3" value='2' autocomplete="off">   <label class="btn btn-outline-primary" for="btncheck3">Checkbox 3</label> </div> <script> function selectOne(event) {     const clickedElement = event.target; ...

Form Validation

Form Validation <!DOCTYPE html> <html> <head>     <title>Form Validation</title>      </head> <body>     <form id="loginForm">         <input type="text" name="username" required placeholder="Username" data-error-msg="Username is required"><br><br>         <input type="password" name="password" required placeholder="Password" data-error-msg="Password is required"><br><br>         <input type='text' class='form-control' data-error-msg="Data required" required>         <!-- Additional form fields -->         <button type="button" id="submitForm">Submit</button>     </form>     <div id="result"></div> </body> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>     <sc...

How to seperate character from string in php

Lets see with example $string = "abcdef"; $result=[]; $strlen = strlen($string); for($i=0;$i<$strlen;$i++) {     $result[$i]=$string[$i];   } print_r($result);     $string = "abcdef"; $result=[]; $strlen = strlen($string); for($i=0;$i<$strlen;$i++) {     $result[$i]=$string[$i]; } print_r($result);

Show json data as drop-down menu

JSON Live Data Search using Ajax JQuery Employee Data Below is the complete code example you can use for live searching employee data with Ajax and jQuery. Copy it into your project files, but here it will display as code for readers: <div class="container" style="width: 900px;"> <h2 align="center">JSON Live Data Search using Ajax JQuery</h2> <h3 align="center">Employee Data</h3> <div align="center"> <input class="form-control" id="search" name="search" type="text" placeholder="Search employee..." /> </div> <ul class="list-group" id="result"></ul> </div> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> $(document).ready(function(){ $.ajaxSetup({ cache: false }); $('#search').keyup(function(){ $('#...

Multiple Images Uploads Step by Step

Lets see with example      <input type="file" name="image[]" id="form-field-2" placeholder="Select News Image For Uploading" class="col-xs-10 col-sm-5" required multiple="multiple" />   <input type="file" name="image[]" id="form-field-2" placeholder="Select News Image For Uploading" class="col-xs-10 col-sm-5" required multiple="multiple" />   <?php   include "connection.php";   if (isset($_POST['submit'])) {     extract($_POST);     $i = 0;     $total = count($_FILES['image']['name']);     for ($i = 0; $i < $total; $i++) {       $tmpFilePath = $_FILES['image']['tmp_name'][$i];       if ($tmpFilePath != "") {         $img = md5(time());         $newFilePath = "" . $img . $_FILES['image']['name'][$i];         if (move_uploaded_file($tmpFilePath, "../event/...

Uploads Only 10 files in month step by step

?   01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 <?php        $con = mysqli_connect( "localhost" , "root" , "" , "demo" );   date_default_timezone_set( 'Asia/Kolkata' );        $date = Date ( "Y-m-d" );                  if (isset( $_POST [ 'submit' ]))      {          extract( $_POST );            $name1 = $_FILES [ 'photo' ][ 'name' ];    $type = $_FILES [ 'photo' ][ 'type' ];    $size = $_FILES [ 'photo' ][ 'size' ];    $temp = $_FILES [ 'photo' ][ 'tmp_name' ];    if ( $name1 ){   $upload = "posts/" ;       ...

How to Delete record using PHP Ajax

index.php ?   01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 <!DOCTYPE html> <html> <head>      <title></title> </head> <body>   <?php        $connection = mysqli_connect( "localhost" , "root" , "" , "db_2018" ) or die (mysqli_error());        $ReadSql = "SELECT * FROM `crud`" ;      $res = mysqli_query( $connection , $ReadSql );   ?>     <table>      <tr>          <th>name</th>          <th>Last Name</th>          <th>email id</th>     ...
Image
How to edit post in Wordpress?

Why you should use CodeIgniter

If you need a framework with small footprint. 1.You need a high performance. 2.Need a framework which requires zero configurations. 3.Need a framework which don't use command line. 4.Need a framework which doesn't require adhering to restrictive coding rules. 5.To get a simplified code structure.

What is Codeigniter?

For building a web application you spend a lot of time in writing the same code again and again. Frameworks provide you a starting block and minimize the amount of code needed to build a website. CodeIgniter is PHP driven framework but it's not a PHP substitute. Diving into CodeIgniter doesn't mean you are leaving PHP behind. PHP is a server-side scripting language for building dynamic web-based applications. CodeIgniter contains libraries, simple interface and logical structure to access these libraries, plug-ins, helpers and some other resources which solve the complex functions of PHP more easily maintaining a high performance. It simplifies the PHP code and brings out a fully interactive, dynamic website at a much shorter time. It supports PHP version of 5.2.6 or newer and MySQL version 4.1 or newer. It makes your web more robust and your code easier to read and maintain. It is a free toolkit, light weight and easier to install. A person using CodeIgniter must be f...