abhi_madhani Posted June 2, 2010 Share Posted June 2, 2010 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 More sharing options...
shino Posted June 2, 2010 Share Posted June 2, 2010 Try instead: $postcodearray[$n] = $postcode; Link to comment https://forums.phpfreaks.com/topic/203586-store-value-in-array-to-next-location/#findComment-1066440 Share on other sites More sharing options...
abhi_madhani Posted June 2, 2010 Author Share Posted June 2, 2010 Hi, Thanks for helping. I am a beginner at PHP, so thanks for helping me out. Regards, Abhishek Link to comment https://forums.phpfreaks.com/topic/203586-store-value-in-array-to-next-location/#findComment-1066445 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.