Jump to content

Array help.


mrhobbz

Recommended Posts

I need some help with an array setup, I'm not 100% sure how to do this.

 

To start off, I have a mysql table that has a name and a few other attributes.  There will be multiple of the name and different, varrying attributes.  Here is the array..

 

while ($row = mysql_fetch_row($result)){
foreach($row as $key=>$value) {
  $raid = $row[1];
  $boss = $row[2];
  $comp = $row[3];
  $status = array (
   array($raid, $boss, $comp)
   );
  
}

 

Basically instead of it creating a seperate array for each row in the table, I want it to merge the array based on the "raid" column. Is there an easy way I can do this or would I be better off using two different databases, one for the "raid" lists and the second for the bosses, querying the "bosses" database and pulling it based on the raid name column?

Link to comment
https://forums.phpfreaks.com/topic/130603-array-help/
Share on other sites

Like this?

 

while ($row = mysql_fetch_row($result)){
  $status[] = array(
   "raid" => $row[1],
   "boss" => $row[2],
   "comp" => $row[3],
)
}

 

Or maybe:

 

while ($row = mysql_fetch_row($result)){
  $status[$row[1]] = array(
   "boss" => $row[2],
   "comp" => $row[3],
)
}

 

Link to comment
https://forums.phpfreaks.com/topic/130603-array-help/#findComment-677566
Share on other sites

Ehh sort of :)  I was more or less looking to stick them all in a single array

 

say i have four rows in my table all with "pizza" as the common raid column and another four rows with "bagel" as the rad column.

 

I'm trying to stick them into an array such as...

 

pizza

->boss->blah

->boss->blah

->boss->blah

->boss->blah

 

bagel

->boss->blah

->boss->blah

->boss->blah

->boss->blah

 

 

I'm thinking it may be easier to just use two databases.

Link to comment
https://forums.phpfreaks.com/topic/130603-array-help/#findComment-677570
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.