Php 数据库中有两个不同的表,我想在一个表中按日期或时间顺序从它们获取数据?

Php 数据库中有两个不同的表,我想在一个表中按日期或时间顺序从它们获取数据?,php,Php,PHP我想从两个表中获取数据,比如从买方记录和从hr接收付款 数据库中有两个不同的表,我想在一个表中按日期或时间顺序从它们获取数据?首先,请使用准备好的语句来避免SQL注入 据我所知,您希望买方从车辆和矿山获取数据,对吗? 在这种情况下,您可以在SQL中获取这两个数据,从中获取买家信息 if(isset($_GET['buyer_id'])){ $buyer_id = $_GET['buyer_id']; $buyer_query = mysqli_query($conn, "S

PHP我想从两个表中获取数据,比如从买方记录和从hr接收付款


数据库中有两个不同的表,我想在一个表中按日期或时间顺序从它们获取数据?

首先,请使用准备好的语句来避免SQL注入

据我所知,您希望买方从车辆和矿山获取数据,对吗? 在这种情况下,您可以在SQL中获取这两个数据,从中获取买家信息

if(isset($_GET['buyer_id'])){
    $buyer_id = $_GET['buyer_id'];
    $buyer_query = mysqli_query($conn, "SELECT * FROM new_entry_table where buyer_id = '$buyer_id'");
    if(mysqli_num_rows($buyer_query) > 1){

        $i = 1;

        while($show = mysqli_fetch_array($buyer_query)){

            $v_p_store = $show['per_vihicle_price'];
            $store_sum = $v_p_store + @$store_sum;
//**************************************
            $vihicle_id = $show['vihicle_id'];
            $select_vihicle = mysqli_query($conn, "SELECT * from vihicles where id = '$vihicle_id'");$store_vihicle = mysqli_fetch_array($select_vihicle);

            $mine_id = $show['id'];
            $select_mines = mysqli_query($conn, "SELECT * from mines where mine_id = '$mine_id'");$store_mine = mysqli_fetch_array($select_mines);
            ?>
            <tr>
                <td><?php echo $i++; ?></td>

                <td><?php echo $show['date']; ?></td>
                <td><?php echo $store_vihicle['vihicle_type'] . " " . $store_vihicle['vihicle_no']; ?></td>
                <td><?php echo $store_mine['mine_name'] . " # " . $store_mine['mine_no']; ?></td>
                <td><?php echo "KG- " . $show['weight']; ?></td>
                <td><?php echo "RS- " . $show['price']; ?></td>
                <td><?php echo "RS- " . $show['per_vihicle_price']; ?></td>
                <td><?php echo "RS- " . $store_sum; ?></td>
                <td>0</td>
            </tr>
        <?php }
    }
}

先生,我的帖子是关于一位买家从我这里借钱买东西的,我会把这笔贷款加到表中,但每当他们支付贷款时,我都想在同一页上显示贷款是以购买价格支付的。
数据库表是不同的。

先生,我的帖子是针对一个买家从我这里借钱购买东西,我打算把这笔贷款添加到表中,但每当他们支付贷款时,我都想显示贷款是按照购买的价格支付的
$sql = "
    SELECT t.id,v.vihicle_type, m.mine_name, t.weight,t.price, t.per_vihicle_price, t.per_vihicle_price   FROM new_entry_table t 
    left join vihicles v on t.vihicle_id = v.id
    left join mines  m on m.mine_id=t.id
where t.buyer_id = '{$buyer_id}' order by t.date desc";