PHP PDO MYSQL - Get Array comma separated from fetchAll -
i'm stuck in this.
i need result (138,139,140,141,142,143,144,145), i'm getting (array,array,array,array,array,array,array,array)...
my code is:
<?php try { $dbconn = dbconnection(); $sql = "select `product_category_id`, `product_category_parent_id`, `date_available`, `status` `product_category` `product_category_parent_id` = '" . $_get['cat'] . "' , `date_available` <= now() , `status` = '1' order `product_category_id` asc"; $stmt = $dbconn -> prepare($sql); $stmt -> execute(); $array = $stmt -> fetchall(pdo::fetch_assoc); foreach($array $row) { $category[] = array($row['product_category_id']); } $subcategory = implode(',', $category); echo $subcategory; } ?>
can please me?
thanks lot!
change
$category[] = array($row['product_category_id']);
for
$category[] = $row['product_category_id'];
Comments
Post a Comment