How to Store Database records in an Multidimentional Array in PHP


About Array in PHP

Like any other programming languages or  web languages, array plays an important role in storing many data.
Storing single array elements in PHP in as any normal languages.
Syntax : array () ;
But to store many array within an array, there are Multidimensional Arrays. PHP have the Array of Array concept. 
Syntax: array (array());

Array in Arrays in PHP to store database values.

Well this post seems to be simple. Yes , i had an issue with storing the values in multidimensional arrays, but there haven't been any proper post till yet, of actual way of storing and dynamic looping used for storing data.

So lets start,
I want to store watches database values. For each watch there are 5 parameters (coloumns).

First I will extract the data from database using select query
$res = mysql_query("select * from watches ") or die(mysql_error());

Next, we should initialize array of array for storing data
$wat = array(array());

Now, below is the simple snippet to dynamically store values in that $wat array.

$i=0;
while($row = mysql_fetch_array($res))
{
$j=0;
  $wat[$i][$j++] = $row['brand'];
  $wat[$i][$j++] = $row['modelname'];
  $wat[$i][$j++] = $row['price'];
  $wat[$i][$j++] = $row['gender'];
  $wat[$i][$j++] = $row['movement'];
  $i++;
}

Now if we want to display all the contents of data in that array, we can do something like this.

for($i=0 ; $i<$rows ; $i++)
      for($j=0 ; $j< $columns; $j++)
      {
        echo $wat[$i][$j]."<br>";
      }
}

So we had store and displayed the data from the database successfully.
If you liked the post, do share and like us at AnonHackSociety

12 comments

Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care.As always, we appreciate your confidence and trust in us...!!! SAP Training in Chennai


Reply

Really very nice blog information for this one and more technical skills are improve,i like that kind of post.



SAP training in Chennai

Reply

I have been following you for a couple of months now but this is my first time commenting on a blog post. Thank you for sharing your knowledge and experience with us. Keep up the good work. Already bookmarked for future reference.

SAP training in Chennai

Reply


That is very interesting; you are a very skilled blogger. I have shared your website in my social networks!


SAP training in Chennai

Reply

All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.


Digital Marketing Company in Chennai

Reply

new year wishes for whatsapp christmas whatsapp pictures christmas nails designs 2016 Many people’s hope to others by writing the letters. They write letters and sent it to their friends, relatives, and the others. This is a beautiful style to wish someone; you can also do this. Many people wish the peoples by the mobile message in the event of Christmas. This is the digital style which uses by the youngster on the events.

Reply

christmas themed nails christmas pictures for facebook new year free wishes 2017 Here you may get all gifts and surprises which you may not get from any other website.

Reply
This comment has been removed by the author.

Are you interested in any kinds of hacking services?
Feel free to contact TECHNECHHACKS@GMAIL.COM.

For years now we’ve helped so many organizations and companies in hacking services.
TECHNECHHACKS is a team of certified hackers that has their own specialty and they are five star rated hackers.

We give out jobs to hackers (gurus only) to those willing to work, with or without a degree, to speed up the availability of time given to jobs!!

Thus an online binary decoding exam will be set for those who needs employment under the teams establishment.


we deal with the total functioning of sites like,



+ SOCIAL MEDIA (Facebook, Twitter, Instagram, Snapchat, google hangout etc.)

+ CREDIT CARDS INSTALLATION

+ WESTERN UNION TRANSFER

+ MONEY FLIPPING

+ BANK ACCOUNTS

+ IOS/OS

+ CRIMINAL RECORDS

+ SCHOOL GRADES

+ CREDIT SCORES

+ SPOUSES PHONE

+ BTC RECOVERY

+ BTC MINING


Thus bewere of scammers because most persons are been scammed and they ended up getting all solutions to their cyber bullies and attacks by US.

I am Jason williams one of the leading hack agent.

PURPOSE IS TO GET YOUR JOBS DONE AT EXACTLY NEEDED TIME REQUESTED!!!



And our WORK SUCCESS IS 100%!!!



I’m always available for you when you need help.

Contact or write us on:

Technechhacks@gmail.com

SIGNED....!

Jason. W.

Reply

Thanks for a wonderful share. Your article has proved your hard work and experience you have got in this field. Brilliant. i love it.
http://livetrainstatus.co.in/

Reply

Well-Written article. It will be supportive to anyone who utilizes it, including me.
Keep doing what you are doing – can't pause to read more posts.
Thanks for the precious help here "Satta King Up"

Reply

Are you interested in any kinds of hacking services?
Feel free to contact TECHNECHHACKS.

For years now we’ve helped so many organizations and companies in hacking services.
TECHNECHHACKS is a team of certified hackers that has their own specialty and they are five star rated hackers.

We give out jobs to hackers (gurus only) to those willing to work, with or without a degree, to speed up the availability of time given to jobs!!

Thus an online binary decoding exam will be set for those who needs employment under the teams establishment.


we deal with the total functioning of sites like,


• SOCIAL MEDIA (Facebook, Twitter, Instagram, Snapchat, google hangout etc.)

• SCHOOL GRADES

• IOS/OS

• CREDIT SCORES

• BANK ACCOUNTS

• SPOUSES PHONE

Our special agents are five star rated agents that specializes in the following, and will specially be assigned to you for a special job well DONE.

• WESTERN UNION TRANSFER

• CREDIT CARDS INSTALLATION

• MONEY FLIPPING

• CRIMINAL RECORDS

• BTC RECOVERY

• BTC MINING

• BTC INVESTMENT

Thus bewere of scammers because most persons are been scammed and they ended up getting all solutions to their cyber bullies and attacks by US.

I am Jason williams one of the leading hack agent.

PURPOSE IS TO GET YOUR JOBS DONE AT EXACTLY NEEDED TIME REQUESTED!!!



And our WORK SUCCESS IS 100%!!!



We’re always available for you when you need help.

Contact or write us on:

Technechhacks@gmail.com

SIGNED....!

Jason. W

TECHNECHHACKS
2021©️All Right Reserved

Reply

Post a Comment