Jump to content

Store value in array to next location


abhi_madhani

Recommended Posts

Hi, Friends

 

I am retrieving records from a database and using a while loop to display each record in tabular format. While displaying each record I am trying to store a section of that record e.g. 'Postcode' in a new custom array.

 

I am trying to store the Postcode of each record at new location of an array. E.g. First record is stored at

[0] => 'EC1N 8WE', then second record is stored at [1] => 'B16 9RE', then third record is stored at [2] => 'TW19 6QW'

, and so on in a same array.

 

Can anybody please guide me as to how can I achieve this.

 

<?php
echo "		<html>
	<body>
	<table>
                <tr>";
		$viewprodSQL="select * from product where fieldname='term' ";
		$exeviewprodSQL=mysql_query($viewprodSQL) or die (mysql_error);
                        $n = 0;
		while ($thisviewprodarray=mysql_fetch_array($exeviewprodSQL))
		{
echo "				<td><img src=".$imgloc." width='125' height='125'></td>";
			$postcode=$thisviewprodarray['p_postcode'];
			$postcodearray=array($n=>'$postcode');
			$n++;
		}
echo "		</tr>
	</table>
	</body>
	</html>";
?>

Link to comment
https://forums.phpfreaks.com/topic/203586-store-value-in-array-to-next-location/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.