Welcome Guest, Not a member yet? Register   Sign In
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



Theme © iAndrew 2016 - Forum software by © MyBB