Hi,
I'm having a hard time understanding how this is supposed to work in my circumstance, perhaps multidimensional array is the wrong term.
I'm used to thinking about this from a different SQL based language, so tell me if this makes no sense. I have two tables in my database (venue, and venue_synonym), they link together based on the venue_id key. I want my array to look something like this (using my other knowledge-set):
1 venue_id
1 beg_active_dt
1 end_active_dt
1 seating_capacity
1 venue_type_cd
1 synonyms[*]
2 synonym_mnemonic
2 synonym_type
2 synonym_beg_active_dt
2 synonym_end_active_dt
etc.
All the 1's are from the venue table, all the 2's are from the venue_synonym table. What I have below seems to work, but I'm not sure that I've really gone about it the proper way. Could someone take a look and let me know if this looks like the right thing to do when pulling all of this data in? Thanks!
$query_1 = "SELECT
v.venue_id,
v.venue_type_id,
v.seating_capacity,
v.active_ind,
v.beg_active_dt,
v.end_active_dt,
v.city,
v.state_country_id
FROM
venue v
WHERE
v.active_ind = 1
AND v.venue_id = 365
ORDER BY
v.venue_id";
$results_1 = mysql_query($query_1) or die(mysql_error());
$v = 0;
$venues = array();
while($row = mysql_fetch_array($results_1))
{
$venues['venue_id'][$v] = $row['venue_id'];
$venues['venue_type_id'][$v] = $row['venue_type_id'];
$venues['seating_capacity'][$v] = $row['seating_capactiy'];
$venues['active_ind'][$v] = $row['active_ind'];
$venues['beg_active_dt'][$v] = $row['beg_active_dt'];
$venues['end_active_dt'][$v] = $row['end_active_dt'];
$query_2 = "SELECT
vs.venue_synonym_id,
vs.venue_id,
vs.mnemonic,
vs.primary_ind,
vs.active_ind,
vs.beg_active_dt,
vs.end_active_dt
FROM
venue_synonym vs
WHERE
vs.venue_id = '".$row['venue_id']."'";
$results_2 = mysql_query($query_2) or die(mysql_error());
$vs=0;
while($row = mysql_fetch_array($results_2))
{
$venues['synonyms'][$v]['venue_synonym_id'][$vs] = $row['venue_synonym_id'];
$venues['synonyms'][$v]['venue_id'][$vs] = $row['venue_id'];
$venues['synonyms'][$v]['mnemonic'][$vs] = $row['mnemonic'];
$venues['synonyms'][$v]['primary_ind'][$vs] = $row['primary_ind'];
$venues['synonyms'][$v]['active_ind'][$vs] = $row['active_ind'];
$venues['synonyms'][$v]['beg_active_dt'][$vs] = $row['beg_active_dt'];
$venues['synonyms'][$v]['end_active_dt'][$vs] = $row['end_active_dt'];
$vs++;
}
$v++;
}