PHP Javascript Array -
hi i'm novice php developer least , i'm pretty stuck.
i'm trying below code working know need foreach loop or similar i'm way out of depth, i'm not sure how working, know of basic stuff i'm lost.
basically receipt when tab settled. searches mysql database relevant items , should print them on receipt.
i know mysql query not linked output @ bottom don't know how it.
<html lang="en"> <head> <title>receipt</title> </head> <body> <?php $invoicenum = $_post['invoicenum']; $name = $_post['name']; $netrev=$invoicenum - 1; ?> items: <? $itemquery = mysql_query("select * sales invoicenum = '$netrev' , tabname = '$name'"); $result = array(); while($row = mysql_fetch_array($itemquery)) { $result[] = $row['itemname']; } echo json_encode($result); $amounts = json_decode($result['amounts']); $items = json_decode($result['items']); $prices = json_decode($result['prices']); ?> <br> <? for ($i = 0; $i < count($items); $i++) { echo $amounts[$i] . "x " . $items[$i] . " - " . $prices[$i] . "<br>"; } ?> </body> </html>
i've removed code isn't relevant array, if can i'd forever grateful.
no need of encode , decode.
$itemquery = mysql_query("select * sales invoicenum = '$netrev' , tabname = '$name'"); while($row = mysql_fetch_array($itemquery)) { echo $row['amounts'] . "x " . $row['items'] . " - " . $row['prices'] . "<br>"; } ?>
Comments
Post a Comment