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