Welcome Guest, Not a member yet? Register   Sign In
Getting data from multiple tables
#8

[eluser]gtech[/eluser]
eventID does not exist in any of you database columns, so thats why you get the error.

your example is slightly different and there may be a better solution, I have adapted the code and put it below... its UNTESTED as I couldn't be bothered to set up the database. Its just an idea so you get the concept,

Use some echos to debug it, or print_r to display array contents (don't forget to take them out as this can result in a headers already sent error message). e.g . print_r($dbres->result_array());

My Untested code:
Code:
..
// print_r($dbres->result_array());

$retarr = array();
foreach ($dbres->result_array() as $key => $dbrow_array) {
  // echo "<br>KEY:".$key."<BR>";
  // print_r($dbrow_array);
  // echo "<br>";
  if (!defined($retarr[$dbrow_array['entry_id']])) {
    $retarr[$dbrow_array['entry_id']] = $dbrow_array;
    $retarr[$dbrow_array['entry_id']]['tags'] = array();
    $retarr[$dbrow_array['entry_id']]['tags'][] = $dbrow_array['tag'];
  } else {
    $retarr[$dbrow_array['entry_id']]['tags'][] = $dbrow_array['tag'];
  }
  // print_r($retarr);

}
// the idea is to return [<entry id>][<db field name>] .. containing the field value
//                       [<entry id>]['tags'][<num>] .. containing the tag name
return $retarr;


Messages In This Thread
Getting data from multiple tables - by El Forum - 11-13-2007, 07:58 PM
Getting data from multiple tables - by El Forum - 11-14-2007, 04:16 AM
Getting data from multiple tables - by El Forum - 11-14-2007, 03:26 PM
Getting data from multiple tables - by El Forum - 11-14-2007, 04:52 PM
Getting data from multiple tables - by El Forum - 11-15-2007, 02:15 AM
Getting data from multiple tables - by El Forum - 11-15-2007, 02:49 AM
Getting data from multiple tables - by El Forum - 11-27-2007, 07:03 PM
Getting data from multiple tables - by El Forum - 11-28-2007, 08:37 AM
Getting data from multiple tables - by El Forum - 11-28-2007, 04:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB