php 用于在一个文本框中回显多个值的 pdo 代码

php pdo code to echo multiple values inside one textbox

字段名称 - 收据编号,优惠券,方案名称

我创建了一个没有收据的表单。

需要根据输入的收据号查询所有的couponno。并且需要在文本框中以逗号分隔格式回显所有优惠券编号。

for ex-- 在我的数据库中...跟随。数据存在..

收据没有优惠券方案名称

一个月701 511

701 512 一个月

701 513 一个月

现在我需要的是select所有701的优惠券和优惠券文本框内的回显。

for ex - 511,512,513 echo all couponno in one textbox.

请帮助我如何做到这一点

<?php
$scheme = "";$book = "";$coup = "";$amou = "";$rec = "";$cit = "";
 $db=new PDO('mysql:host=localhost;dbname=circulation_scheme_prepaid','root','');
if($_POST && isset($_POST['submit']))
{
    $result=$db->prepare('SELECT scheme_name,coupon, FROM scheme_master WHERE receipt_no=:receipt_no');
    $result->bindParam(':receipt_no',$_POST['receipt_no']);
    $result->execute();
    foreach($result as $row){    
        $scheme =  $row['scheme_name'];         
        $coup =  $row['coupon'];  
    }
}?>

**receipt no textbox** - I get input from this textbox
<input type="text" name="receipt_no"  /> 

我需要在文本框下方回显所有优惠券编号。

优惠券文本框 - <input type="text" name="coupon" value="<?php echo $coup;?>" class="field size2" />

这应该有效。

<?php
$scheme = "";$book = "";$coup = "";$amou = "";$rec = "";$cit = "";
 $db=new PDO('mysql:host=localhost;dbname=circulation_scheme_prepaid','root','');
if($_POST && isset($_POST['submit']))
{
    $result=$db->prepare('SELECT scheme_name,coupon, FROM scheme_master WHERE receipt_no=:receipt_no');
    $result->bindParam(':receipt_no',$_POST['receipt_no']);
    $result->execute();
    $data = $result->fetchAll();
    $coupons = array();

    foreach($data as $row){    
        $coupons[] = $row['coupon']; 
    }
}?>

<input type="text"  value="<?php echo implode(',', $coupons); ?>"/> 
<?php
$scheme = "";$book = "";$coup = "";$amou = "";$rec = "";$cit = "";
$db=new     PDO('mysql:host=localhost;dbname=circulation_scheme_prepaid','root','');
if($_POST && isset($_POST['submit']))
{
    $result=$db->prepare('SELECT coupon FROM scheme_master WHERE receipt_no=:receipt_no');
    $result->bindParam(':receipt_no',$_POST['receipt_no']);
    $result->execute();
    $data = $result->fetchAll();

    foreach($data as $row) {    
       $value[] = end($row); 
     }
     $coupons = implode(',', $value);
}?>


<input type="text"  value="<?php echo $coupons ?>"/>