0

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,

enter image description here

In output, i stored no 11, but array is only show 1.

output : 691

1
  • 1
    Use explode() to "explode" the string by , Commented Dec 4, 2019 at 10:32

2 Answers 2

1

Can you try to explode() function:

$results[] = explode(',', $row['assign']);

foreach($results as $result) {
    echo $result.'/n';
}
Sign up to request clarification or add additional context in comments.

Comments

1

Use explode() to convert from string to array

$a = "1,2,3";
$d = explode(',',$a);
print_r($d);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.