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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.