Jump to content

Konohamaru

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Konohamaru's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. That's a good structure to use (as a backup if i cant figure this out), but I what I really want to do is basically display all the menu items on one page sorting by their ID. For example: SOUPS (ID = 1) items 1 items 2 SALADS (ID = 2) items 1 items 2 My problem is updating the results to query and show the next ID. Here's my current code: [code] <?php $n = 1; If ($n == 1) { $name = "Soups"; } ElseIf ($n == 2) { $name = "Salads"; } ElseIf ($n == 3) { $name = "Appetizers"; } ElseIf ($n == 4) { $name = "Entrees"; } Elseif ($n == 5) { $name = "Sushi"; } Elseif ($n == 6) { $name = "A la Carte"; } Elseif ($n == 7) { $name = "Desserts"; } Elseif ($n == 8) { $name = "Beverages"; } if ($_GET['act'] == 'sushi') { $getList = $sql->query("SELECT id, description, pricing FROM sushi " . " WHERE id=$n ORDER BY id ASC") or die('Could not connect to the database!'); $admin->html .= html_list_start($name); $n++; while ($Result = $sql->fetch_array($getList)) { $admin->html .= html_list_result($Result); } $admin->html .= html_list_end(); } function html_list_start($name) { return <<<HTML <div class="thead">&raquo; {$name}</div> <table class="intable"> HTML; } function html_list_result($Result) { return <<<HTML <tr> <td class="content">{$Result['description']}</td> </tr> HTML; } function html_list_end() { return <<<HTML </table><br> HTML; } ?> [/code]
  2. I'm trying to do a resturant website with PHP. I'm trying to make our menu editable via admin interface. Field 1 is called [b]ID[/b], Field 2 is called [b]DESCRIPTION[/b], and Field 3 is called [b]PRICING[/b]. What I'm trying to do is seperate each row by their [b]ID[/b]. For example: SOUPS [EDIT] Item 1 [EDIT] Item 2 APPETIZERS [EDIT] Item 1 [EDIT] Item 2 ---- ETC ---- This is their ID groups. [code]+Field 1 1 = soups 2 = salads 3 = appetizers 4 = entrees 5 = sushi 6 = a la carte 7 = dessert 8 = beverages +Field 2 Description +Field 3 Pricing[/code] And this is my current code so far: [code] <?php if ($_GET['act'] == 'sushi') { $getList = $sql->query("SELECT id, description, pricing FROM sushi " . " ORDER BY id ASC") or die('Could not connect to the database!'); $admin->html .= html_list_start();   while ($soupResult = $sql->fetch_array($getList))   {     $admin->html .= html_list_result($soupResult);   } $admin->html .= html_list_end(); } function html_list_start() { return <<<HTML <br> <div class="thead">&raquo; Drunken Fish Sushi Menu </div> <div> <table class="intable"><br> HTML; } function html_list_result($soupResult) { return <<<HTML <tr> <td class="content">{$soupResult['description']}</td> </tr> HTML; } function html_list_end() { return <<<HTML </table></div> HTML; } ?> [/code] I know it seems messy and unfinished, but I just need to know how to sort by ID and print each groupings seperately. Thanks for any assisstance. Criticism is welcome.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.