Please don't ask why.... <grin>

I have multiple arrays coming from a database...
I know that I can join the tables to match the primary key fields...

But let's say you work in a very large corporation, and your db admins refuse to join the team.... <grin>

How can I bring in multiple arrays and join them by primary key fields inside the php script....

Example:
while (($row1 = sybase_fetch_array($query1)) && ($row2 = sybase_fetch_array($query2))) {
$data1 = $row1['Org_Id'];
$data2 = $row1['data1'];
$data3 = $row2['Org_Id'];
$data4 = $row2['data2'];

$tr .= "
<tr><td>$data1</td><td>$data2</td><td>$data3</td><td>$data4</td></tr>
";
}

How can I match the Org_Id fields? and return these to a table loop...

    maybe you should key the array on Org_Id, then loop over it:

    while (($row1 = sybase_fetch_array($query1)) && ($row2 = sybase_fetch_array($query2))) { 
    /*
    $data1 = $row1['Org_Id']; 
    $data2 = $row1['data1']; 
    $data3 = $row2['Org_Id']; 
    $data4 = $row2['data2']; 
    */
    $data[$row1['Org_Id']] = array($row1['data1'], $row2['data2']);
    }
    
    while (list($org_id, $subarray) = each($data))
    {
    $tr .= "
    <tr>
    <td>Org ID: $org_id</td>
    <td>{$subarray[0]}</td>
    <td>{$subarray[1]}</td>
    </tr> 
    "; 
    }
    

    hope that helps
    /nick

      Write a Reply...