Topic: php

MySQL MULTIPLE INNER JOINS Example 0

MySQL MULTIPLE INNER JOINS Example

Today, We want to share with you MySQL MULTIPLE INNER JOINS Example.In this post we will show you MySQL INNER JOIN By Practical Examples, hear for Join two tables on multiple columns we will give you demo and example for implement.In this post, we will learn about mysql multiple inner join with where clause with an example.

MySQL MULTIPLE INNER JOINS Example

There are the Following The simple About MySQL MULTIPLE INNER JOINS Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Multiple inner joins with multiple tables, so the MySQL Joining Two or More Tables for this example is following below.

Syntax

INNER JOIN Syntax

SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;

Example 1: INNER JOIN

INNER JOIN Example

SELECT Products.ProductID, Members.MemberName
FROM Products
INNER JOIN Members ON Products.MemberID = Members.MemberID;

Example 2: JOIN Three Tables

JOIN Three Tables Example

SELECT Products.ProductID, Members.MemberName, owners.ShipperName
FROM ((Products
INNER JOIN Members ON Products.MemberID = Members.MemberID)
INNER JOIN owners ON Products.ShipperID = owners.ShipperID);

Example 3: INNER JOIN with GROUP BY

MySQL INNER JOIN with GROUP BY clause

SELECT 
    T1.tinOrderNo,
    status,
    SUM(quantityOrdered * productPrice) total
FROM
    Products AS T1
        INNER JOIN
    orderdetails AS T2 ON T1.tinOrderNo = T2.tinOrderNo
GROUP BY tinOrderNo;

Example 4: INNER JOIN using operator

MySQL INNER JOIN using operator other than equal

SELECT 
    tinOrderNo, 
    productName, 
    msrp, 
    productPrice
FROM
    products p
        INNER JOIN
    orderdetails o ON p.productcode = o.productcode
        AND p.msrp > o.productPrice
WHERE
    p.productcode = 'S10_9898';

Example 5: Ambiguous Columns

Ambiguous Columns in MySQL Inner Join

USE company;
SELECT First_Name, Last_Name, Education, 
  DeptID, dname, Member_salary,
        Yearly_Income, Sales
FROM employ
  INNER JOIN department
    ON employ.DeptID = department.DeptID;

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 MULTIPLE INNER JOINS Example.
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 MySQL Database Connectivity Examples 0

PHP MySQL Database Connectivity

Today, We want to share with you PHP MySQL Database Connectivity.In this post we will show you , hear for database connection in php with mysqli example we will give you demo and example for implement.In this post, we will learn about how to connect html form to mysql database using php with an example.

PHP MySQL Database Connectivity

There are the Following The simple About PHP MySQL Database Connectivity Full Information With Example and source code.

As I will cover this Post with live Working example to develop php database connection example program, so the some php mysql select database for this example is following below.

Example 1: Simple PHP Connect to MySQL

db_config.php

$host="localhost";
$user="root";
$password="Your_password";
$con=mysql_connect($host,$user,$password);
if(!$con) {
  echo '<h1>Good Luck, Connected to MySQL</h1>';
} else {
   echo '<h1>MySQL Server is not connected</h1>';
}

Example 2: MySQL Connection Using PHP Script

phpmysqlconnect.php

$host="localhost";
$user="root";
$password="";
$con=mysql_connect($host,$user,$password);
if(!$con) {
  echo '<h1>Connected to MySQL</h1>';
  //if connected then Select Database.
  $db=mysql_select_db("YOUR_DATABASE_NAME",$con);
  $query=mysql_query("YOUR_MYSQL_QUERY",$db);
}
else {
  echo '<h1>MySQL Server is not connected</h1>';
}

Example 3: PHP MySQL: Connecting to MySQL Database

PHP and MySQL Programming/Database Connectivity(phpmysqlconnect.php)

<html>
   <head>
      <title>Simple PHP Connecting MySQL Server</title>
   </head>
   <body>
      <?php
         $dbhost = 'localhost:3306';
         $dbuser = 'root or //any';
         $dbpass = 'mydatabase_passwords';
         $conn = mysql_connect($dbhost, $dbuser, $dbpass);
         
         if(! $conn ) {
            die('Could not connect: ' . mysql_error());
         }
         echo 'Your Database Connected successfully';
         mysql_close($conn);
      ?>
   </body>
</html>

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 MySQL Database Connectivity.
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 Multidimensional Array Remove Duplicates 0

PHP Multidimensional Array Remove Duplicates

Today, We want to share with you PHP Multidimensional Array Remove Duplicates.In this post we will show you unique multidimensional array, hear for how to remove array duplicate in php we will give you demo and example for implement.In this post, we will learn about PHP Remove Duplicates From Multidimensional Array with an example.

PHP Multidimensional Array Remove Duplicates

There are the Following The simple About PHP Multidimensional Array Remove Duplicates Full Information With Example and source code.

As I will cover this Post with live Working example to develop array_unique in laravel, so the some array_map in php for this example is following below.

Way : 1 PHP Multidimensional Array Remove Duplicates:

Remove duplicate values from multidimensional array in PHP

function check_multi_unique($src){
     $results = array_map("unserialize",
     array_unique(array_map("serialize", $src)));
   return $results;
}

//Call function

$reqDataArray=array( array("name","name"), 
            array("age","12"), 
            array("name","parvez"), 
            array("add","delhi")
     );

$results=check_multi_unique($reqDataArray);

Example 2: remove duplicate values from a multi-dimensional array in PHP

$input = array_map("unserialize", array_unique(array_map("serialize", $input)));
print_r($input);

Example 3 : PHP Remove Duplicates From Multidimensional Array

<?php
    function super_unique($array,$key)
    {
       $temp_array = [];
       foreach ($array as &$v) {
           if (!isset($temp_array[$v[$key]]))
           $temp_array[$v[$key]] =& $v;
       }
       $array = array_values($temp_array);
       return $array;

    }


$my_arr="";
$my_arr[0]['id']=0;
$my_arr[0]['product']="HDK";
$my_arr[1]['id']=1;
$my_arr[1]['product']="DEF";
$my_arr[2]['id']=2;
$my_arr[2]['product']="JDK";
$my_arr[3]['id']=3;
$my_arr[3]['product']="HDK";

echo "<pre>";
print_r($my_arr);
echo "****---------------unique-------------------------***<br/>";
print_r(super_unique($my_arr,'product'));

?>

Way 2: Remove duplicate Values:

$my_arr = Array(
          Array('Magento','example'),
          Array('vuejs','Laravel'),
          Array('Magento','example'),
          Array('c++','angularjs')
        );

$my_arr = array_map("unserialize", array_unique(array_map("serialize", $my_arr)));

print_r($my_arr);

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 Multidimensional Array Remove Duplicates.
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 Jquery Ajax Upload Multiple Images with Preview 0

PHP Jquery Ajax Upload Multiple Images with Preview Example

Today, We want to share with you PHP Jquery Ajax Upload Multiple Images with Preview Example.In this post we will show you multiple image upload in laravel using ajax, hear for multiple image upload in php with database we will give you demo and example for implement.In this post, we will learn about multiple image upload with preview and delete jquery php with an example.

PHP Jquery Ajax Upload Multiple Images with Preview Example

There are the Following The simple About PHP Jquery Ajax Upload Multiple Images with Preview Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop how to upload multiple images in php using for loop, so the some image upload using ajax php mysql for this example is following below.

Step 1 : Javascript Code:

jQuery Source code

<script>
$(document).ready(function(){
    $('#submitForm').ajaxForm({
        target:'#products_imgPrev',
        beforeSubmit:function(){
            $('#status').html('<img src="image.gif"/>');
        },
        success:function(){
            $('#imgs').val('');
            $('#status').html('');
        },
        error:function(){
            $('#status').html('Sorry Your products_img uploading failed, please try again.');
        }
    });
});
</script>

Step 2 : HTML Code:

HTML Source Code:

<form method="post" id="submitForm" enctype="multipart/form-data" action="upload.php">
    <label>Choose products_img</label>
    <input type="file" name="products_img[]" id="imgs" multiple >
    <input type="submit" name="submit" value="UPLOAD"/>
</form>
<div id="status"></div>


<div class="gallery" id="products_imgPrev"></div>

Step 3 : PHP Source Code:

PHP Code: (upload.php)

<?php
if(isset($_POST['submit'])){

    $target_dir = "uploads/";
    $allow_types = array('jpg','png','jpeg','gif');
    
    $products_img_arr = array();
    foreach($_FILES['products_img']['name'] as $key=>$val){
        $image_name = $_FILES['products_img']['name'][$key];
        $tmp_name   = $_FILES['products_img']['tmp_name'][$key];
        $size       = $_FILES['products_img']['size'][$key];
        $type       = $_FILES['products_img']['type'][$key];
        $error      = $_FILES['products_img']['error'][$key];
        
        
        $file_name = basename($_FILES['products_img']['name'][$key]);
        $uploadFileImgDir = $target_dir . $file_name;
        
        
        $file_type = pathinfo($uploadFileImgDir,PATHINFO_EXTENSION);
        if(in_array($file_type, $allow_types)){    
            
            if(move_uploaded_file($_FILES['products_img']['tmp_name'][$key],$uploadFileImgDir)){
                $products_img_arr[] = $uploadFileImgDir;
            }
        }
    }
    
   
    if(!empty($products_img_arr)){ ?>
        <ul>
        <?php foreach($products_img_arr as $image_src){ ?>
            <li><img src="<?php echo $image_src; ?>" alt=""></li>
        <?php } ?>
        </ul>
<?php }
}
?>

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 Jquery Ajax Upload Multiple Images with Preview Example.
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.