Reputation: 938
i stored data by using multiple checkbox in mysql. i want to show this stored data without include comma by using array. but, it is shown as the array was count comma
index.php
include('config.php');
$results = array();
$sql = "select * from assign1 where id='1'";
$run = mysqli_query($mysqli,$sql);
while($row = mysqli_fetch_assoc($run)) {
$results[] = $row['assign']; ?>
<p><?php print_r($results) ?></p>
<?php echo $results[0][0] ."".$results[0][2]."". $results[0][4] ?>
<?php } ?>
In mysql,
In output, i stored no 11, but array is only show 1.
output : 691
Upvotes: 0
Views: 77
Reputation: 237
Use explode() to convert from string to array
$a = "1,2,3";
$d = explode(',',$a);
print_r($d);
Upvotes: 1
Reputation: 2945
Can you try to explode()
function:
$results[] = explode(',', $row['assign']);
foreach($results as $result) {
echo $result.'/n';
}
Upvotes: 1