• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retrieving data from multiple tables

#2
[eluser]danmontgomery[/eluser]
I think you're making this more complicated than it needs to be... You only need one query:

Code:
$sql = "SELECT categoryTable.categoryTitle, categoryTable.categoryId, userMenuTable.cookieId, userMenuTable.menuEntryId, categoryTable.categoryOnline,
categoryTable.categoryIsSpecial, categoryTable.categoryDateCreated, categoryTable.categorySlug, categoryTable.dashboardUserId, categoryTable.categoryAbstract
FROM categoryTable
JOIN userMenuTable ON categoryTable.categoryId = userMenuTable.categoryId
WHERE userMenuTable.cookieId = 'some_string'";

Code:
if(isset($mainMenu)) {
  foreach ($mainMenu as $k => $v) {
    echo "<li class='menuItem'>
      <a href='".base_url()."welcome/getContent/$v[categoryId]' class='" . ( strlen($v["menuEntryId"]) ? "saved " : "" ) . "navLink' id='$v[categoryTitle]'>".$v['categoryTitle']."</a>
      </li>";
  }
} else {
  ...
}

You're not very clear about what you're trying to accomplish (or maybe I'm just confused by the db structure)... If that's not what you're looking for, can you be more specific about the result you're trying to get?


Messages In This Thread
Retrieving data from multiple tables - by El Forum - 02-15-2010, 06:15 AM
Retrieving data from multiple tables - by El Forum - 02-15-2010, 08:54 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.