根据sql中的COUNT语句显示文本框行

Purchase_item table:

itemid | prfno | qty | desc  | serialno
1      |123    |1    |iphone | 4566
2      |123    |1    |ipad   |76844
3      |456    |1    |server |68540
4      |679    |1    |LGG2   |7850

I want to display all the data that has the same prfno like this

prfno: 123
qty   | desc    | serialno
1     |iphone   |4566
1     |ipad     |76844

My problem is that I can only display the data using array. I can't pass it in a variable which I can use to place in an input tag. Here's my code for array.

$prfno=$row['prfno'];
$pr="Select prfno, qty, desc, serial from purchase_item where prfno='$ppid'";
$pru=$db->prepare($pr);
$pru->execute();
$purch= $pru->fetchAll();
print_r($purch);

thanks!

If you need to pass an array, then use implode() function and IN clause like this

$array = array(10, 20, 30);
$sql ="SELECT * FROM table WHERE value IN(" . implode(",", $array) . ")";
// execute query

If the array elements are strings, modify the above like this

$array = array('first', 'second', 'third');
$sql ="SELECT * FROM table WHERE value IN('" . implode("','", $array) . "')";