|
Posted by nemo on 10/07/87 11:20
I posted this in alt.php.sql and got no reply. Can anyone here help?
When a friend asked me to do a website for his Chinese restaurant, I
foolishly said "No problem". Trouble is he wants his Menus (Soups,
Appetisers, Sweet and Sour, etc) in three columns and he will, from time to
time, be changing the content of each menu and creating temporary Menus to
cater for Ladies Nights, Chinese-significant times of year, Chinese Party
Nights, and the like. Like so -
Col 1 ------------ Col2 ---------------- Col3
menu 1 --------- menu 2 ---------- menu 3
menu 4 --------- menu 5 ---------- menu 6
etc.
To avoid any large blanks resulting from Menu 1 having three elements and
Menu 2 having twenty elements and Menu 3 having six elements, and so on, I
want to offer him the ability of which Menu he puts where. This will depend
upon the position of each Menu in an array, with the Menu's position in the
array to be controlled by the order in which the names of each Menu are
called from the database table "menu_names". But I can't get the logic
right.
table_name="menu_names"
id menu_name
50 Soups
80 Appetisers
etc
// assemble array of menu names
$Query="SELECT menu_name FROM menu_names ORDER BY id ";
$Result=mysql_db_query ($DBName, $Query, $Link);
while ($Row=mysql_fetch_array ($Result))
{
$menu_array[]=$Row[menu_name];
}
There is an individual table for each Menu.
table_name=[name_of_a_menu, e.g. "appetisers"]
id ---- dish --- price
1 ---- Calamari Rings ---- 2.90
3 ---- Spicy Salted Garlic Chicken Popcorn ---- 2.90
etc
I now want to go as per my sort'v standard 3-across code (sorry, not up to
speed on CSS yet) -
// 3 across
$i=0;
$num_across=3;
$TableName="$menu_array[N]";
$Query="SELECT * FROM $TableName ";
$Result=mysql_db_query ($DBName, $Query, $Link);
while ($Row=mysql_fetch_array ($Result))
{
if ($i==0) print ("<tr>");
if ( ($i>0) && ( $i%$num_across==0) ) print ("</tr><tr>");
print("<td>$Row[ STUFF ]</td>");
$i++;
}
such that the "STUFF" in each cell is a self-contained Menu like the
following (minus the cosmetics) -
$TableName=$menu_array[N];
$Query="SELECT * FROM $TableName ORDER BY id ";
$Result=mysql_db_query ($DBName, $Query, $Link);
while ($Row=mysql_fetch_array ($Result))
{
print("<tr><td>$Row[dish]</td><td>£ $Row[price]</td></tr>");
$num++;
}
So... how do I ensure each cell across contains the list of items in one
Menu?
I *had* thought that just by stating the problem (if I've even managed to do
*that* correctly), the answer would surface (as is often he case with me)
but alas, no - which leads me to think I'm 'way off-base.
Can anyone help spare my blushes, please?
Navigation:
[Reply to this message]
|