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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -