Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 仅显示一次同名数据_Php_Mysql - Fatal编程技术网

Php 仅显示一次同名数据

Php 仅显示一次同名数据,php,mysql,Php,Mysql,我需要显示我的账单历史记录,以便用户可以通过单击提交自动提交。但我不需要显示所有交易,只需要显示每个账单名称,所以我应该使用选择DISTINCT对吗 <?php $query3 = "SELECT DISTINCT billing_name, billing_reference_num FROM billing_history"; $result3 = mysqli_query($link, $query3) or die(mysqli_error($link)); while ($row

我需要显示我的账单历史记录,以便用户可以通过单击提交自动提交。但我不需要显示所有交易,只需要显示每个账单名称,所以我应该使用
选择DISTINCT
对吗

<?php
$query3 = "SELECT DISTINCT billing_name, billing_reference_num FROM billing_history";
$result3 = mysqli_query($link, $query3) or die(mysqli_error($link));
while ($row3 = mysqli_fetch_array($result3)) {
    $billing_name = $row3['billing_name'];
    $billing_reference_num = $row3['billing_reference_num'];
    ?>
    <td><?php echo $billing_name ?></td>
    <td><?php echo $billing_reference_num ?></td>
    <?php
    $queryBill = "SELECT * FROM billing_history WHERE billing_name = '$billing_name'";
    $resultBill = mysqli_query($link, $queryBill) or die(mysqli_error($link));
    while ($row4 = mysqli_fetch_array($resultBill)) {
        $billing_name_id = $row4['billing_name_id'];
        $account_id = $row4['account_id'];
        $account_number = $row4['account_number'];
    }
    ?>
    <td><input type="text" name="transaction_amount"/></td>
    <td><input type="submit" value="Submit"/></td>
    <input type="hidden" name="billing_name_id" value="<?php echo $billing_name_id ?>"/>
    <input type="hidden" name="billing_name" value="<?php echo $billing_name ?>"/>
    <input type="hidden" name="billing_reference_num" value="<?php echo $billing_reference_num ?>"/>
    <input type="hidden" name="account_number" value="<?php echo $account_number ?>"/>
    <input type="hidden" name="account_id" value="<?php echo $account_id ?>"/>


有两件事情不能很好地结合:账单信息和sql漏洞。你似乎没有什么经验,但正在处理付款细节。我强烈建议找一位有经验的开发人员来做这件事。(别误会我的意思,学习很好,在生产服务器上乱花钱是不行的)@samuel嘿,我只是在做一个模拟网站