0

私は Authorize.net ゲートウェイに取り組んでいます

$sql= "select *  from shop where cusid = '1'";
 $sqlexc= mysql_query($sql) or die(mysql_error());

$line_items = array();
while ($title = mysql_fetch_array($sqlexc)) {
    $line_items[] = ('Coupon',' $title[6]', '1', '0.99', 'Y');
}

以下の種類の配列を作成する方法

/*    $line_items = array(
    "Coupon1','description','2','10.99','Y'",
    "Coupon2','description','2','10.99','Y'",
    "Coupon3','description','2','10.99','Y'",);*/
4

2 に答える 2

0

ええと.. まったく同じにしたい場合は...

$i=0;
$line_items = array();   
while ($title = mysql_fetch_array($sqlexc)) {
    $line_items[] = "Coupon" . ++$i . "', '" . $title[6] . "', '2', '10.99', 'Y'";
}

ただし、mysql_fetch_array よりも mysql_fetch_assoc を使用します (実際には、mysql は非推奨であるため、PDO に切り替えます)。

于 2012-06-30T02:50:07.803 に答える
0
$line_items = array();
while ($title = mysql_fetch_array($sqlexc)) {
    $line_items[] = $title;
}
foreach ($line_items as $row){
    echo $row[0]." ".$row[1]." ".$row[2]." ".$row[3]."<br>";
}
于 2012-06-30T04:03:06.327 に答える