I'm working on a project to store information, i need to save datas in my database using a multiple select option. after saving to database it will store like this Item1,item2,item3
separating with comers. Now i need to echo it out from database so it will display like this
item1
item2
item3
i don't want it to display the way it is in my database Item1,item2,item3
Here is more explanatory image
Here is my multiple select image sample
Here is how i want to output to be like
Please i don't have any sample code because i don't know how to start writing this and am very new in php i also don't know what to search online but i know you can help me.
Store the string into a variable and use explode()
function to make an array of items. Example:
$string = 'item1, item2, item3';
$arrayOfItems = explode(',', $string);
foreach($arrayOfItems as $item) {
echo '<button>'.$item.'</button>';
}
$data="item1,item2,item3"; $dt=explode(",",$data); for($i=0;$i< count($dt); $i++) { echo "".$dt[$i].""; } ?>
If the data is stored like item1,item2,item3 in the database. Then show it as is to the value of the textbox. For ex:-
<input type="text" value="<?php echo $items; // item1,item2,item3 ?>">