php-pdo代码在一个文本框中回显多个值


php pdo code to echo multiple values inside one textbox

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

我创建了一个没有文本框的表单。

需要根据输入的收据编号搜索所有优惠券编号,并需要在文本框内以逗号分隔格式回复所有优惠券编号

在我的数据库中。。。foll。存在数据。。

收据无优惠券方案名

701 511一个月

701 512一个月

701 513一个月

现在我需要选择701的所有优惠券,并在优惠券文本框内回复

对于ex-511512513,在一个文本框中回显所有couponno

请帮我做这个

<?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"  /> 

我需要在下面的文本框中回复所有优惠券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 ?>"/>