I have a table for clients that stores some basic info but in one row it also stores an array that looks something like this i.e. "1-1, 2-1, 3-1, 6-1, 7-1, 16-1, 17-1, 18-1"
the commas separate the "options", the number before the dash is the "option" ID, and the number after after the dash is the "option's" "quantity". each client might have different "options" with different "quantities"
I have this so far but I have no idea where to go from here.
<?php
$out = "";
$id_client ="";
$id_client = $_SESSION['client_cod_card'];
$sql="SELECT * FROM customer WHERE client_cod_card='$id_client'";
$result = mysql_query ($sql);
while ($row = mysql_fetch_array($result)){
$in = $row['options'];
$out = str_replace(',', '<br />', $in);
echo $out;} ?>
and it gives me this
1-1
2-1
3-1
6-1
7-1
16-1
17-1
18-1
is there any way to echo that string into something like:
$option_id - $option_quantity
$option_id - $option_quantity
$option_id - $option_quantity
$option_id - $option_quantity
..
so I can use those numbers and get each option's info from another table and adjust the quantity.
I hope I managed to explain this somewhat understandable and I hope someone can give me a hand as this is the most frustrating thing I've gotten myself into. Thank you all in advance!
json_encode()instead, but once again storing serialized data like OP wants to is a super bad idea in the first place.