I want to get the list of the columns and not the rows in the implode
, but it's giving me an error, but gives me the result of a row when I use the index number of the array.
<?php
// this is the database connection
$session_id = session_start();
$con = mysqli_connect("localhost", "root", "", "ecommerce");
?>
<!DOCTYPE html>
<html>
<head>
<title>array</title>
</head>
<body>
<?php
$sql_select = "SELECT * FROM cart";
$run_select = mysqli_query($con, $sql_select);
$datas = [];
if(mysqli_num_rows($run_select) > 0) {
while($show = mysqli_fetch_assoc($run_select)) {
$id[] = $show;
}
}
$avengers = implode(",", $id['1']);
// i want to echo out the columns this is giving me the rows
echo $avengers;