Topic: Mysql

Ajax Image Upload without Refreshing Page using Jquery 0

Ajax Image Upload without Refreshing Page using Jquery

Today, We want to share with you Ajax Image Upload without Refreshing Page using Jquery.In this post we will show you Upload an image without refreshing page in php, hear for PHP Image upload without refreshing page using jquery example we will give you demo and example for implement.In this post, we will learn about Image Upload Without Refreshing Page Using JQUERY, PHP & MYSQLi with an example.

Ajax Image Upload without Refreshing Page using Jquery

There are the Following The simple About Ajax Image Upload without Refreshing Page using Jquery Full Information With Example and source code.

As I will cover this Post with live Working example to develop Image Upload without Page Refresh with PHP and jQuery with Demo, so the PHP Image upload without refreshing page using jquery example is following below.

php image upload no refresh script

index.php

In this example Full source code for Image Upload Without Refreshing Page Using JQUERY, PHP & MYSQLi

<html lang="en">
<head>
<title>PHP - Image Uploading with Form JavaScript Example - pakainfo.com</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" >

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> 
<script src="http://malsup.github.com/jquery.form.js"></script> 
<script> 
        $(document).ready(function() { 
            $(".upload-image").click(function(){
            	$(".form-horizontal").ajaxForm({target: '.img_previews'}).submit();
            });
        }); 
</script>
</head>
<body>
	<nav class="pakainfo navbar navbar-default">
		<div class="pakainfo container-fluid">
		<div class="pakainfo navbar-header">
		<a class="pakainfo navbar-brand" href="#">Free Source code For PHP - Image Uploading with Form JavaScript Example</a>
		</div>
		</div>
	</nav>
	<div class="pakainfo container">
	<form action="imageuploadpro.php" enctype="multipart/form-data" class="form-horizontal" method="post">
		<div class="img_previews"></div>
		<input type="file" name="image" class="pakainfo form-control" style="width:50%" />
		<button class="btn btn-success upload-image">Upload</button>
	</form>
	</div>
</body>
</html>

And then, now make a simple another PHP file for fetch php post http request as well as files or image uploading source code, Therefor make a PHP imageuploadpro.php file and put the simple bellow source code:

imageuploadpro.php

here server side Source Code for image upload without refreshing page using jquery Example

<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root(username)');
define('DB_PASSWORD', 'My_password');
define('DB_DATABASE', 'pakainfo_database');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);

if(isset($_POST) && !empty($_FILES['image']['name'])){
	
	$name = $_FILES['image']['name'];
	list($txt, $ext) = explode(".", $name);
	$uploaded_img_name = time().".".$ext;
	$tmp = $_FILES['image']['tmp_name'];


	if(move_uploaded_file($tmp, 'upload/'.$uploaded_img_name)){
		mysqli_query($db,"INSERT INTO items (title)
		VALUES ('".$uploaded_img_name."')");
		echo "<img width='300px' src='upload/".$uploaded_img_name."' class='img_previews'>";
	}else{
		echo "Sorry !!, Your images uploading failed";
	}

}
?>

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Ajax Image Upload without Refreshing Page using Jquery.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

PHP MySQLi Insert Update Delete Query Builder 0

PHP MySQLi Insert Update Delete Query Builder

Today, We want to share with you PHP MySQLi Insert Update Delete Query Builder.In this post we will show you INSERT, UPDATE and DELETE with mysqli, hear for PHP OOPs dynamic insert update delete data in MySQLi we will give you demo and example for implement.In this post, we will learn about Create a Simple CRUD Database App: Connecting to MySQLi with PHP with an example.

PHP MySQLi Insert Update Delete Query Builder

There are the Following The simple About PHP MySQLi Insert Update Delete Query Builder Full Information With Example and source code.

As I will cover this Post with live Working example to develop Update Data in MySQL Database Table Using PHP with MySQLi, so the php MySQLi code for updating data in mysql database for this example is following below.

Connect to Database

The PHP MySqli Simple two basic ways to connect to the database Like as a procedural and object oriented

$mysqli =  mysqli_connect('host','root','my_pwd','aisd');

$mysqli = new mysqli('host','root','my_pwd','aisd');

“object-oriented” Get Errors

<?php
$mysqli = new mysqli('host','your_uname','pwd','atmiya25');

if ($mysqli->connect_error) {
    die('Sorry, Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}

?>

SELECT Multiple Records

PHP mysqli SELECT Multiple Records as Associative array

<?php
$mysqli = new mysqli('host','root-uname','db_pass','atmiya25');

if ($mysqli->connect_error) {
    die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}

$results = $mysqli->query("SELECT id, member_code, member_desc, reputations FROM members");

print '<table border="1">';
while($row = $results->fetch_assoc()) {
	print '<tr>';
    print '<td>'.$row["id"].'</td>';
	print '<td>'.$row["member_code"].'</td>';
	print '<td>'.$row["member_name"].'</td>';
	print '<td>'.$row["member_desc"].'</td>';
	print '<td>'.$row["reputations"].'</td>';
	print '</tr>';
}  
print '</table>';

$results->free();

$mysqli->close();
?>

PHP MySQLi SELECT Multiple Records as Array

fetch_array() : Function returns an array

<?php
$mysqli = new mysqli('host','root-uname','db_pass','atmiya25');

if ($mysqli->connect_error) {
    die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}

$results = $mysqli->query("SELECT id, member_code, member_desc, reputations FROM members");

print '<table border="1"';
while($row = $results->fetch_array()) {
	print '<tr>';
    print '<td>'.$row["id"].'</td>';
	print '<td>'.$row["member_code"].'</td>';
	print '<td>'.$row["member_name"].'</td>';
	print '<td>'.$row["member_desc"].'</td>';
	print '<td>'.$row["reputations"].'</td>';
	print '</tr>';

}   
print '</table>';
$results->free();

$mysqli->close();
?>

PHP MySQLi SELECT Multiple Records as Objects

<?php
$mysqli = new mysqli('host','root-uname','db_pass','atmiya25');

if ($mysqli->connect_error) {
    die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}

$results = $mysqli->query("SELECT id, member_code, member_desc, reputations FROM members");

print '<table border="1">';
while($row = $results->fetch_object()) {
	print '<tr>';
    print '<td>'.$row->id.'</td>';
	print '<td>'.$row->member_code.'</td>';
	print '<td>'.$row->member_name.'</td>';
	print '<td>'.$row->member_desc.'</td>';
	print '<td>'.$row->reputations.'</td>';
	print '</tr>';
}  

print '</table>';

$mysqli->close();
?>

SELECT Single value

<?php
$mysqli = new mysqli('host','root-uname','db_pass','atmiya25');

if ($mysqli->connect_error) {
    die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}

$member_name = $mysqli->query("SELECT member_name FROM members WHERE id = 1")->fetch_object()->member_name; 
print $member_name; //output value

$mysqli->close();
?>

PHP MySQLi SELECT COUNT Total records of a table

<?php
$mysqli = new mysqli('host','root-uname','db_pass','atmiya25');

if ($mysqli->connect_error) {
    die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}

$results = $mysqli->query("SELECT COUNT(*) FROM members");
$get_total_rows = $results->fetch_row(); //hold total records in variable

$mysqli->close();
?>

PHP MySQLi SELECT Using Prepared Statements

$search_member = "MD1001"; //member id

$query = "SELECT id, member_code, member_desc, reputations FROM members WHERE member_code=?";
$statement = $mysqli->prepare($query);

$statement->bind_param('s', $search_member);

$statement->execute();

$statement->bind_result($id, $member_code, $member_desc, $reputations);

print '<table border="1">';

while($statement->fetch()) {
	print '<tr>';
    print '<td>'.$id.'</td>';
	print '<td>'.$member_code.'</td>';
	print '<td>'.$member_desc.'</td>';
	print '<td>'.$reputations.'</td>';
	print '</tr>';

}   
print '</table>';

//close connection
$statement->close();

PHP MySQLi Insert or Update if record already exists

Simple Insert or Update if record already exists Query

$id = 0; 
$member_code = "M98256";
$member_name = "Krunal Sisodiya";
$member_desc = "Best friends To Parag shukla from DSP study Points";
$reputations = "1000";

$query = "INSERT INTO members (id, member_code, member_name, member_desc, reputations) 
			VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE member_code=?, member_name=?, member_desc=?, reputations=?";

$statement = $mysqli->prepare($query);

$statement->bind_param('dsssdsssd', $id, $member_code, $member_name, $member_desc, $reputations, //insert vars
									 $member_code, $member_name, $member_desc, $reputations); //update vars

$statement->execute();

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP MySQLi Insert Update Delete Query Builder.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Laravel Create Read Update Delete Query Builder 0

Laravel Create Read Update Delete Query Builder

Today, We want to share with you Laravel Create Read Update Delete Query Builder.In this post we will show you laravel insert or update multiple records, hear for CRUD (Create Read Update Delete) in a Laravel App we will give you demo and example for implement.In this post, we will learn about laravel query builder insert or update – Update or create with an example.

Laravel Create Read Update Delete Query Builder

There are the Following The simple About Laravel Create Read Update Delete Query Builder Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel eloquent update multiple records, so the laravel db insert if not exists for this example is following below.

Creating and Update Laravel Eloquent

laravel query builder insert or update Example

Suppose you have Member table, where in which organization_Id and email is unique, Now lets see the below in best example we’ll display you can use latest version of the laravel query builder to MySQL Database update or insert in simple MySQL single laravel query.

$email = $request->email;
$organizationId = $request->organizationId;
Member::updateOrCreate(['email' => $email, 'organization_Id' => $organizationId], [
    'email' => $email,
    'organization_Id' => $organizationId,
    .
    .
    .
    .
    //other Database MySQL columns as per your requirements 
  ]);

In above Laravel query builder updateOrInsert or updateOrCreate example, laravel MySQL query builder will process where member email and organization id is exists in the MySQL table or not. If Data exists, it will simple MySQL update the row else it will MySQL Table insert or create the new row in the member table. You can also use simple updateOrInsert instead of updateOrCreate.

Update or create using Laravel

$email = $request->email;
$organizationId = $request->organizationId;
Member::updateOrInsert(['email' => $email, 'organization_Id' => $organizationId], [
    'email' => $email,
    'organization_Id' => $organizationId,
    .
    .
    .
    .
    //other Members columns as per your MySQL Database requirements 
  ]);

Laravel Inserting if record not exist, updating if exist

$product = Product::firstOrNew(array('product' => Input::get('product')));
$product->count += Input::get('available');
$product->save();

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Create Read Update Delete Query Builder.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

PHP Laravel Eloquent Increments and Decrements value 0

PHP Laravel Eloquent Increments and Decrements value

Today, We want to share with you PHP Laravel Eloquent Increments and Decrements value.In this post we will show you laravel increment multiple columns, hear for laravel db::statement,laravel increment column with update we will give you demo and example for implement.In this post, we will learn about How to increment or decrement a column value in Laravel with an example.

PHP Laravel Eloquent Increments and Decrements value

There are the Following The simple About PHP Laravel Eloquent Increments and Decrements value Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel increment and decrement column, so the php – how to use increment() and decrement() in laravel for this example is following below.

In this Best Laravel Post, We would like to Learn you the simple logic for hidden and useful methods of Laravel’s Main join Eloquent ORM to Data value Increment automatically as well as the data Decrement value of the special fields in the main database Mysql column. In my School Management project in Laravel, We used this Main functions Like Laravel Eloquent increment() as well as Laravel decrement() methods to data Value increase and decrease the below numbers respectively.

Laravel increment and decrement column

How to increment or decrement a column value in Laravel?

Students::find($StudentsID)->increment('total_student_count'); // +1
Students::find($StudentsID)->decrement('total_student_count'); // -1

Students::find($StudentsID)->increment('total_student_count', 10); // +10
Students::find($StudentsID)->decrement('total_student_count',10); // -10

increment or decrement a column value in Laravel Example

$loyer = loyer::find($loyer_id);
$criminals = $loyer->criminals + 1;
$loyer->update(['criminals' => $criminals]);

Laravel Increment a column value

    loyer::find($loyer_id)->increment('criminals');
	//or 
    loyer::find($loyer_id)->increment('criminals',2);

Laravel Decrement a column value

loyer::find($loyer_id)->decrement('criminals');

//or
loyer::find($loyer_id)->decrement('criminals',2);

//Laravel using DB query builder
DB::table('loyers')->increment('criminals');

//Laravel using DB query builder
DB::table('loyers')->decrement('criminals');

//Laravel using update query
loyer::where('id', $loyer_id)->update(['criminals' => DB::raw('criminals + 1')]);

//Laravel using update query
loyer::where('id', $loyer_id)->update(['criminals' => DB::raw('criminals - 1')]);

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Laravel Eloquent Increments and Decrements value.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Concat Multiple MySQL Rows GROUP_CONCAT 0

Concat Multiple MySQL Rows GROUP_CONCAT

Today, We want to share with you Concat Multiple MySQL Rows GROUP_CONCAT.In this post we will show you Combine Multiple child rows into one row MYSQL, hear for Select Multiple Rows and Combine / Insert into One Row using MYSQL we will give you demo and example for implement.In this post, we will learn about Concatenate multiple MySQL rows into one field using GROUP_CONCAT with an example.

Concat Multiple MySQL Rows GROUP_CONCAT

There are the Following The simple About Concat Multiple MySQL Rows GROUP_CONCAT Full Information With Example and source code.

As I will cover this Post with live Working example to develop MySQL Concat Multiple Rows Into A Single Row, so the mysql – Combining multiple rows into single column for this example is following below.

Simple MySQL Concat Multiple Rows Into A Only 1 MySQL Row is less want to thing while simple Mysql querying.

Within the MySQL Table

SELECT ID, GROUP_CONCAT(cats SEPARATOR ', ') FROM Members_cats GROUP BY ID

With Other MySQL Table

SELECT member.ID, member.email, GROUP_CONCAT(cat.name SEPARATOR ', ') , member.status FROM `Members`as member, `Members_cats` as cat WHERE member.ID = cat.member_id GROUP BY member.ID ORDER BY member.ID DESC

Example : Mysql group_concat multiple columns

MySQL 3 Tables

CREATE TABLE `displays` (
  `display_id` int(2) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  PRIMARY KEY (`display_id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

CREATE TABLE `students` (
  `stud_id` int(2) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  PRIMARY KEY (`stud_id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

CREATE TABLE `display_student` (
  `id` int(2) NOT NULL AUTO_INCREMENT,
  `display_id` int(2) NOT NULL,
  `stud_id` int(2) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

using GROUP_CONCAT

SELECT display_id, GROUP_CONCAT(DISTINCT stud_id ORDER BY stud_id) AS stud_id_list FROM display_student GROUP by display_id ORDER BY display_id

simple MySQL modify query as well as use the GROUP_CONCAT and GROUP

SELECT s.name AS `show`, 
GROUP_CONCAT(p.name ORDER BY p.name SEPARATOR ', ' ) AS team
FROM display_student sp, displays s, students p 
WHERE sp.display_id = s.display_id AND sp.stud_id = p.stud_id 
GROUP BY sp.display_id ORDER BY s.name

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Concat Multiple MySQL Rows GROUP_CONCAT.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

MySql comma separated column join using PHP Laravel 0

MySql comma separated column join using PHP Laravel

Today, We want to share with you MySql comma separated column join using PHP Laravel.In this post we will show you Search Comma Separated values using FIND_IN_SET in Laravel Query Builder, hear for MySQL query with join and comma separated values in column in Laravel we will give you demo and example for implement.In this post, we will learn about php Laravel join two tables using a comma-separated-list with an example.

MySql comma separated column join using PHP Laravel

There are the Following The simple About MySql comma separated column join using PHP Laravel Full Information With Example and source code.

As I will cover this Post with live Working example to develop find_in_set mysql,find in set in laravel ? example, so the use FIND_IN_SET in Laravel 5.1 with where raw method for this example is following below.

Syntax find_in_set() method

FIND_IN_SET(needle,haystack);

Step 1: Simple SQL Query

SELECT
    `live_products`.*, GROUP_CONCAT(products.name) as productname 
FROM `live_products` 
LEFT JOIN `products` ON FIND_IN_SET(products.id,live_products.products) > '0' 
GROUP BY `live_products`.`id`

And then I can convert this Core sql query into PHP Latest Framework laravel, Therefor I can use Laravel FIND_IN_SET() in MySQL like as bellow simple convert query example using Laravel Query Builder:

Step 2: Laravel 5.7 MySql Query Builder:

$data = \DB::table("live_products")
        ->select("live_products.*",\DB::raw("GROUP_CONCAT(products.name) as productname"))
        ->leftjoin("products",\DB::raw("FIND_IN_SET(products.id,live_products.products)"),">",\DB::raw("'0'"))
        ->groupBy("live_products.id")
        ->get();

at the last You can below see output will be like as Example as a:

Step 3: Final Output

Illuminate\Support\Collection Object
(
    [items:protected] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 1
                    [name] => How to install LaravelBook?
                    [products] => 1,2
                    [created_at] => 2019-01-06 00:00:00
                    [updated_at] => 2019-01-06 00:00:00
                    [productname] => PHPBook,LaravelBook
                )
            [1] => stdClass Object
                (
                    [id] => 2
                    [name] => How to work with PHPBook?
                    [products] => 1
                    [created_at] => 2019-01-06 00:00:00
                    [updated_at] => 2019-01-06 00:00:00
                    [productname] => PHPBook
                )
        )
)

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about MySql comma separated column join using PHP Laravel.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

PHP Laravel Datatable Server Side Processing using jQuery 0

PHP Laravel Datatable Server Side Processing using jQuery Ajax

Today, We want to share with you PHP Laravel Datatable Server Side Processing using jQuery Ajax.In this post we will show you Datatables Server Side Processing in Laravel 5.7, hear for datatables Laravel server-side processing in codeigniter using ajax we will give you demo and example for implement.In this post, we will learn about jQuery Datatable Server Side Processing With Custom Operations using Laravel with an example.

PHP Laravel Datatable Server Side Processing using jQuery Ajax

There are the Following The simple About PHP Laravel Datatable Server Side Processing using jQuery Ajax Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel server side processing for Datatables, so the laravel 5.7 datatables package for this example is following below.

Step 1: include Datatables CSS file and Javascript files from CDN

<link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<script type="text/javascript" language="javascript" src="http://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>

Step 2: HTML table in Laravel Blade File

Here are the steps to be followed for Implement datatables server side processing Laravel

Let the Laravel blade view page be datatable.blade.php. Your HTML Data table columns may be all the different but the step by step (laravel datatables tutorial) here.

<h3>List of The All Articles Title</h3>
<table class="table table-bordered" id="article_datatables">
    <thead>
           <th>Id</th>
           <th>Title</th>
           <th>Action</th>
          
    </thead>                
</table>

Step 3: javascript Source code

And then call simple Laravel Ajax using javascript source code given below. This ajax will automatically call action when you load your page.Below we can ajax request source code. Put this laravel datatables ajax source code to your Laravel blade view page of laravel at the bottom with laravel datatables pagination.

<script>
    $(document).ready(function () {
        $('#article_datatables').DataTable({
            "processing": true,
            "serverSide": true,
            "ajax":{
                     "url": "/fetch_all_articles’",
                     "dataType": "json",
                     "type": "POST",
                     "data":{ _token: "{{csrf_token()}}"}
                   },
            "columns": [
                { "data": "id" },
                { "data": "title" },
                { "data": "action" }
            ]    

        });
    });
</script>

Step 4: Laravel Define Route

Put Laravel Route in your web.php files

And then we want set Laravel route for this method, so we have to go to routes/web.php file and write following source code for set route for index method.

Route::post(‘/fetch_all_articles’,’[email protected])

Step 5: Source code for fetchAllArticles function in ArticleController

jQuery Live Server side Datatable for pagination, records and search filters in laravel datatable server side.

 public function fetchAllArticles(Request $request)
    {

        $columns = array(
            0 => 'id',
            1 => 'title',
        );
        $totalTitles = Article::where('deleted_at', '=', null)
            ->count();
        $totalFiltered = $totalTitles;

        $limit = $request->input('length');
        $start = $request->input('start');
        $order = $columns[$request->input('order.0.column')];
        $page_dir = $request->input('order.0.dir');

        if (empty($request->input('search.value'))) {
            $titles = Article::where('deleted_at', '=', null)
                ->offset($start)
                ->limit($limit)
                ->orderBy($order, $page_dir)
                ->get();
        } else {
            $string_search = $request->input('search.value');

            $titles = Article::where('title', 'LIKE', "%{$string_search}%")
                ->where('deleted_at', '=', null)
                ->offset($start)
                ->limit($limit)
                ->orderBy($order, $page_dir)
                ->get();

            $totalFiltered = Article::where('title', 'LIKE', "%{$string_search}%")
                ->where('deleted_at', '=', null)
                ->count();
        }

        $all_products_data = array();
        if (!empty($titles)) {
            $count = 1;
            foreach ($titles as $title) {

                $nestedData['id'] = $count;
                $nestedData['title'] = $titles->title;
                $nestedData['action'] = '<button type="button" class="btn btn-success" onclick="" title="Edit">
                                        </button>
                                        <button type="button" style="margin-left:6px;" class="btn btn-success" onclick="" title="Article Delete">
                                        </button>';
                $all_products_data[] = $nestedData;
                $count++;
            }
        }

        $product_data = array(
            "draw" => intval($request->input('draw')),
            "recordsTotal" => intval($totalTitles),
            "recordsFiltered" => intval($totalFiltered),
            "data" => $all_products_data,
        );
        echo json_encode($product_data);
 }

Code Understanding

$request – In this case by default all datatables parameters are gets that are sent by jquery ajax serever side datatable.

$totalTitles – totalTitles are the sum all thr count that will be used for Ajax call jquery Datatables pagination in your Laravel Serverside datatable.

$limit – page data record limit is the set variable that init mode number of data records to be get at a time. ( No of total data records to display on page one )

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Laravel Datatable Server Side Processing using jQuery Ajax.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Laravel Check if Object is empty Examples 0

Laravel Check if Object is empty Examples

Today, We want to share with you Laravel Check if Object is empty Examples.In this post we will show you Determine whether a variable is empty in Laravel, hear for Laravel Example to Check if a String is Empty or Null we will give you demo and example for implement.In this post, we will learn about Laravel Check if the Object request is empty before for each with an example.

Laravel Check if Object is empty Examples

There are the Following The simple About Laravel Check if Object is empty Examples Full Information With Example and source code.

As I will cover this Post with live Working example to develop How to check Object is empty or not in PHP/Laravel, so the laravel check if eloquent object is empty for this example is following below.

check if an object is empty in laravel

@if(!$contacts->isEmpty())
//display contacts
@else
You dont have contacts
@endif

Laravel check Object is empty or not in Controller

Determine whether a variable is empty using Laravel

if (!empty($contacts))
if (!contacts->isEmpty())
if (count($contacts) > 0)
if ($contacts->count() > 0)

laravel check if eloquent object is empty

@if($contacts->isEmpty())
    {{ 'Empty' }} 
@else
    {{ 'you have data' }}
@endif

Check if Object is Empty in Laravel

@if(count($contacts) > 0)
//Display contacts
@else
//No contacts
@endif

Laravel check if collection is empty

//isEmpty()

collect([])->isEmpty();// true
//Example
$result->isEmpty()

isNotEmpty()

collect([])->isNotEmpty();// false

//Example
if($results->isNotEmpty())
{
//do something
}

laravel check if eloquent object is empty

foreach($mentors as $mentor)
    @if($mentor->intern->count() > 0)
    @foreach($mentor->intern as $intern)
        <tr class="table-row-link" data-href="/werknemer/{!! $intern->employee->EmployeeId !!}">
            <td>{{ $intern->employee->FirstName }}</td>
            <td>{{  $intern->employee->LastName }}</td>
        </tr>
    @endforeach
    @else
        Mentor don't have any intern
    @endif
@endforeach

Laravel check if collection is empty

if ($mentor->first()) { } 
if (!$mentor->isEmpty()) { }
if ($mentor->count()) { }
if (count($mentor)) { }

Check if Eloquent Relationship is Empty

if (is_null($user->mediaProfile)) { ... }
//or
$model->relation->count();
//or
$model->relation()->exists()
//or
Model::has('relation')->get()
//or
if(!is_null($model->relation)) {
   ....
}

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Check if Object is empty Examples.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

PHP Laravel MySQL Joins Tutorial with Examples 0

PHP Laravel MySQL Joins Tutorial with Examples

Today, We want to share with you PHP Laravel MySQL Joins Tutorial with Examples.In this post we will show you PHP Laravel 5.7 select with join subquery example, hear for Laravel Eloquent Join problem with same column names we will give you demo and example for implement.In this post, we will learn about PHP Laravel MySQL INNER, OUTER, LEFT, RIGHT, CROSS JOINS Tutorial with an example.

PHP Laravel MySQL Joins Tutorial with Examples

There are the Following The simple About PHP Laravel MySQL Joins Tutorial with Examples Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel 5.7 Join with subquery in Query Builder Example, so the some laravel join,join query in laravel controller for this example is following below.

Laravel Eloquent Join problem with same column names

DB::table('product')
->join('price','product.productid','=','price.productid')
->leftJoin('purchaseitem','product.productid','=','purchaseitem.productid')
->where('product.name','=','Iphone 6 Brand')
->select('*')
->get();

PHP Laravel select with join subquery example

$data = DB::table("items")
->select("items.*","available_items.quantity_group")
->join(DB::raw("(SELECT 
    available_items.id_product,
    GROUP_CONCAT(available_items.quantity) as quantity_group
    FROM available_items
    GROUP BY available_items.id_product
    ) as available_items"),function($join){
        $join->on("available_items.id_product","=","items.id");
})
->groupBy("items.id")
->get();

print_r($data);

laravel eloquent join 3 tables

$products = DB::table('products')
->join('members', 'members.id', '=', 'products.member_id')
->join('follows', 'follows.member_id', '=', 'members.id')
->where('follows.follower_id', '=', 3)
->get();

laravel eloquent join with condition

return $query->join('dsp_shop', function($join)
{
    $join->on('dsp_shop.id', '=', 'dsp_feeds.shop_id');
})
->select('Your Any required column names') 
->where('dsp_shop.active', 1)
->get();

Laravel 5 – inner join with multiple conditions example using Query Builder

$member = Member::select("members.*","items.id as itemId","types_emp.id as types_emp_id")
->join("items","items.member_id","=","members.id")
->join("types_emp",function($join){
$join->on("types_emp.member_id","=","members.id")
    ->on("types_emp.item_id","=","items.id");
})
->get();
print_r($member);

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Laravel MySQL Joins Tutorial with Examples.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

PHP Laravel Inline CRUD Using jQuery and AJAX 0

PHP Laravel Inline CRUD Using jQuery and AJAX

Today, We want to share with you PHP Laravel Inline CRUD Using jQuery and AJAX.In this post we will show you Create Inline CRUD Using PHP, Laravel, jQuery and AJAX, hear for HTML5 Inline Editing with Laravel 5.7, MYSQL & jQuery Ajax we will give you demo and example for implement.In this post, we will learn about Inline Table Editing using jQuery Ajax Laravel and MySQL with an example.

PHP Laravel Inline CRUD Using jQuery and AJAX

There are the Following The simple About PHP Laravel Inline CRUD Using jQuery and AJAX Full Information With Example and source code.

As I will cover this Post with live Working example to develop jQuery AJAX Inline CRUD with PHP Laravel, so the jQuery AJAX Inline CRUD using PHP Laravel MySQL for this example is following below.

Phase 1 : Install Laravel Application

Simple HTML5 Inline Editing with Laravel 5.7, MYSQL & jQuery Ajax

Laravel 5.7 version application using bellow composer command

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

Phase 2: MySQL .env files Database Configuration

database configuration in Laravel env files

.env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=MyDBNAme
DB_USERNAME=DATABASE_USERNAME
DB_PASSWORD=MY_DATABASE_PASSWORD

Phase 3: Make a productlist Table and Model

make a Laravel migration for productlist table using Laravel 5.7

Table Name : productlist

php artisan make:migration create_productlist_table

database/migrations

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTagslistTable extends Migration
{
    public function up()
    {
        Schema::create('productlist', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('productlist');
    }
}

run simple Laravel commands migration

Make a Laravel 5.7 migration and Model

php artisan migrate

php artisan make:model ProductList

app/ProductList.php

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ProductList extends Model
{
    public $table = "productlist";
    public $fillable = ['name'];
}

Phase 4: Define Laravel Routes

routes/web.php

Route::get("multipleInptFrm","[email protected]");
Route::post("multipleInptFrm","[email protected]");

Phase 5: Create ProductController

create new controller as ProductController

php artisan make:controller ProductController

app/Http/Controllers/ProductController.php

<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\ProductList;
use Validator;

class ProductController extends Controller
{
    public function moreAddData()
    {
        return view("moreAddData");
    }
    public function moreAddDataPost(Request $request)
    {
        $rules = [];
        foreach($request->input('name') as $key => $value) {
            $rules["name.{$key}"] = 'required';
        }

        $validator = Validator::make($request->all(), $rules);
        if ($validator->passes()) {

            foreach($request->input('name') as $key => $value) {
                ProductList::create(['name'=>$value]);
            }

            return response()->json(['success'=>'done']);
        }
        return response()->json(['error'=>$validator->errors()->all()]);
    }
}

Phase 6: Make a Laravel Blade File

resources/views/moreAddData.blade.php

<!DOCTYPE html>
<html>
<head>
    <title>Inline Table Editing using jQuery Ajax Laravel and MySQL - Pakainfo.com</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  

 
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  
    <meta name="csrf-token" content="{{ csrf_token() }}">
</head>
<body>


<div class="container">
    <h2 align="center">Laravel - HTML5 Inline Editing with Laravel 5.7, MYSQL & jQuery Ajax</h2>  
    <div class="form-group">
         <form name="product_name_add" id="product_name_add">  


            <div class="alert alert-danger message-errors-display" style="display:none">
            <ul></ul>
            </div>


            <div class="alert alert-success message-display" style="display:none">
            <ul></ul>
            </div>


            <div class="table-responsive">  
                <table class="table table-bordered" id="dynamic_field">  
                    <tr>  
                        <td><input type="text" name="name[]" placeholder="Enter your Name" class="form-control name_list" /></td>  
                        <td><button type="button" name="add" id="add" class="btn btn-success">Add More</button></td>  
                    </tr>  
                </table>  
                <input type="button" name="submit" id="submit" class="btn btn-info" value="Submit" />  
            </div>


         </form>  
    </div> 
</div>


<script type="text/javascript">
    $(document).ready(function(){      
      var postURL = "<?php echo url('multipleInptFrm'); ?>";
      var i=1;  


      $('#add').click(function(){  
           i++;  
           $('#dynamic_field').append('<tr id="row'+i+'" class="dynamic-added"><td><input type="text" name="name[]" placeholder="Enter your Name" class="form-control name_list" /></td><td><button type="button" name="remove" id="'+i+'" class="btn btn-danger btn_remove">X</button></td></tr>');  
      });  


      $(document).on('click', '.btn_remove', function(){  
           var button_id = $(this).attr("id");   
           $('#row'+button_id+'').remove();  
      });  


      $.ajaxSetup({
          headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
          }
      });


      $('#submit').click(function(){            
           $.ajax({  
                url:postURL,  
                method:"POST",  
                data:$('#product_name_add').serialize(),
                type:'json',
                success:function(data)  
                {
                    if(data.error){
                        displayMessageError(data.error);
                    }else{
                        i=1;
                        $('.dynamic-added').remove();
                        $('#product_name_add')[0].reset();
                        $(".message-display").find("ul").html('');
                        $(".message-display").css('display','block');
                        $(".message-errors-display").css('display','none');
                        $(".message-display").find("ul").append('<li>Record Inserted Successfully.</li>');
                    }
                }  
           });  
      });  


      function displayMessageError (msg) {
         $(".message-errors-display").find("ul").html('');
         $(".message-errors-display").css('display','block');
         $(".message-display").css('display','none');
         $.each( msg, function( key, value ) {
            $(".message-errors-display").find("ul").append('<li>'+value+'</li>');
         });
      }
    });  
</script>
</body>
</html>

run command

php artisan serve

// open bellow URL
http://localhost:8000/multipleInptFrm

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Laravel Inline CRUD Using jQuery and AJAX.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.