I execute query that return for me a fields of my first database in HTML table and one of this fields field "number" and i want to query another database using the same field "number" to return a field "price" in my second database.

"number" it's the same filed in my two databases. 

How can I do that in php ?

This my Code PHP :

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

                    $pro_date = $_POST['date'];
                    $sql = "
                           SELECT 
                             left(list_product_order.number,8) as number,
                             list_product_order.created_at as date,
                             date(list_product_order.received) as received_date,
                             date(list_product_order.deliv) as deliv_date,
                             list_product_order.four_name as name,
                             COUNT(id_product_order) as items,
                             MONTH(list_product_order.created_at) as month,
                             -1 as price

                           FROM `list_product_order`

                           WHERE YEAR(list_product_order.created_at) = $date

                           GROUP BY list_product_order.number,month

                           ORDER BY list_product_order.created_at DESC 

                           ";

                           $datao->exec ( "set names utf8" );
                           $req = $datao->prepare($sql);
                           $req->execute();
                           $fquery = $req -> fetchAll(PDO::FETCH_ASSOC);

                }

                 $sqll = "
                         SELECT 
                         data_command.number as number,
                         data_command.sup_name as sup_name,
                         SUM(data_command_item.value * data_command_item.quantity) as price                                              

                         FROM data_command
                         LEFT JOIN data_command_item on data_command.id_number = data_command_item.fk_number
                         WHERE (data_command_item IN (implode(',',$fquery)))
                         ";

                   $datam->exec ( "set names utf8" );
                   $req = $datam->prepare($sqll);
                   $req->execute();
                   $squery = $req -> fetchAll(PDO::FETCH_ASSOC);
                         ?>

         <div class="panel-body">
             <?php if(isset($_POST['pro_date']))  
             { 

             foreach($fquery as $key => $value)
                      {
                         foreach($squery as $value2)
                         {
                             if($value['number'] === $value2['number'])
                             {
                                $fquery[$key]['four_name'] = $value2['sup_name'];
                                  $fquery[$key]['price'] = $value2['price'];

                             }               
                         }
                       }

                       echo '

                       <table class="table table-striped table-bordered table-hover display" id="table_with_sorting" style="zoom: 85%">
                       <thead>
                       <tr>
                       <th style="font-size:11px">Number</th>
                       <th style="font-size:11px">Date</th>
                       <th style="font-size:11px">Name</th>
                       <th style="font-size:11px">Items</th>
                       <th style="font-size:11px">Received_date</th>
                       <th style="font-size:11px">Deliv_date</th>
                       <th style="font-size:11px">Month</th>
                       <th style="font-size:11px">Price</th>
                     </tr>
                     </thead>
                     <tbody>';
               <?php

                   foreach($fquery as $f)
                    {
                    echo "
                         <tr style='text-align: center;'>
                         <td>".$f['number']."</td>
                         <td>".$f['date']."</td>
                         <td>".$f['name']."</td>
                         <td>".$f['items']."</td>
                         <td>".$f['received_date']."</td>
                         <td>".$f['deliv_date']."</td>
                         <td>".$f['month']."</td>
                         <td>".$f['price']."</td>
                         </tr>";
                  }

                  echo" </tbody>
                   </table>";
                   ?>

                    <?php   }
                        ?>
                                </div>
                            </div>
                        </div>
                            <?php
                        ?>
                </div>

```

This my query for second database : 

```
SELECT 

      data_command.number as number,
      data_command.sup_name as sup_name,
      SUM(data_command_item.value * data_command_item.quantity) as price                                              

FROM  data_command

LEFT JOIN data_command_item on data_command.id_number = data_command_item.fk_number

```

It display for me one number with -1 in price.

[![enter image description here](https://i.stack.imgur.com/hLO8Z.png)](https://i.stack.imgur.com/hLO8Z.png)

Thanks for any help.