Hey guys I'm looking for a solution to a little problem, the PHP seems to be functioning properly and I can't see any problems with the SQL Query, can anybody see anything blatantly wrong with my code? I'm really stuck here.
the contents of the "items" row are similar to the following:
30->0,31->0,32->0,36->0,33->10,29->0,35->0,6->0,5->0,8->0,9->0,7->0,14->0,15->0,10->0,17->0
I just need them to explode into an array and foreach value in that array, print on the page with their appropriate "key". I've looked here: explode() into $key=>$value pair and arrived at no conclusion - this is the full code, if anybody could help me out, tell me what I'm doing or maybe even point me in the right direction I'd be really happy.
$id = $_GET['order'];
if(!is_number($id)){
exit();
}
$sql = "SELECT * FROM ORDERS WHERE id='$id'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$dataString = $row["items"];
foreach (explode(",", $dataString) as $cLine) {
list ($cKey, $cValue) = explode('->', $cLine, 2);
$itemarray[$cKey] = $cValue;
}
foreach($itemarray as $key => $value) {
echo "<br/>".$value." x ".$key;
}
}
} else {
echo "0 results";
}
Thanks.