co.ador Posted May 19, 2009 Share Posted May 19, 2009 I found this link to olive Garden http://www.olivegarden.com/menus/ which it has resemblance to what I want to achieved. If you check at the bottom of the page there are four thumbnails with one image and some text align="center" each. 1. Lunch Menu 2. Dinner Menu 3. Beverage Menu 4. Dessert Menu Now to the left of the web page you will see a <ul> list with a heading call Our Menu the list looks similar to the one below 1. Specials 2. Lunch 3. Dinner 4. Beverage 5. To go! 6. Dessert If you click on the Lunch Menu Thumbnail at the bottom of the web page, you will realize that it will link you to a page that open the Lunch heading of the <ul> list, displaying all the subheadings within the Lunch heading. My question is how that achieved? I know that through the link of the thumbnails the user is directed to a page where it get to activate the while loop embed in the <ul> list to display the subheadings within the Lunch heading line in the <ul> list. My question could that be achieved? How many queries would be needed to achieve this requests and effects? how this queries would look like? And the most important of all How I would get the while loop in the <ul> list to display only the subheadings of the heading being refered to, from the thumbnail link? I know it would be like referring to an specific position inside of the array of the while loop in the <ul> list but how or something similar or maybe there is another way not sure. I just been having difficulties to putting it together. This is the code I have so far, it has an looped <Ul> list and a looped <table></table> which display the thumbnails. $sql = 'SELECT id,Subject FROM menusubjects;'; $result = mysql_query($sql); if($result && mysql_num_rows($result)!=0) { echo '<ul id="nav-categories">'; while($row = mysql_fetch_assoc($result)) { $uri = 'example1.php?subject='.urlencode($row['id']); $class = !is_null($cat) && $cat==$row['id']?' class="selected"':''; echo "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>'; if($submenu==false && !is_null($cat) && $cat == $row['id']) { // line 58 $sql2 = 'SELECT id,shoename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';'; $result2 = mysql_query($sql2); if($result2 && mysql_num_rows($result2)!=0) { echo "\n\t\t",'<ul class="submenu">',"\n"; while($row2 = mysql_fetch_assoc($result2)) { $uri2 = $uri.'&menu='.urlencode($row2['id']); $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':''; echo "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['shoename'],'</a></li>',"\n"; } echo "\t\t",'</ul> <!-- end of ul.submenu -->',"\n"; } $submenu = true; } echo '</li>',"\n"; } echo '</ul> <!-- end of ul#nav-categories -->',"\n $sql = "SELECT menusubjects.Subject, menusubjects.image FROM menusubjects"; $result = mysql_query($sql, $connection); if(!$result){ die("Database query failed:" . mysql_error());} while ($content = mysql_fetch_array($result)) { echo "<table width="260\" height=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#FF0033\" bgcolor=\"#FFFFFF\" style=\"float:left; position:relative; left:206px; top: 300px; height:5px;\"> <td width=\"95%\ height=\"10%\"> <table width=\"96%\" height=\"10%\"> <td style=\"width:100%\"><img src=\"../images/lineforheader.gif\" alt=\"gf\" width=\"100%\" /></td><tr><td bordercolor=\"#666666\" bgcolor=\"#D83607\" height=\"100%\" style=\" width:140px;\"><a href=\"#\"> <div class=\"shoe2\" align=\"left\" style=\"background-image:url(../images/titleshoe.gif);\">" . $content['Subject'] . "</div> </a></td></tr> <tr> <td style=\"width:100%; background:#CC0000; height:2px;\"><a href=\"#\">" . $content['image'] . "</a></td> </tr></table></td> </table></td>"; } Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/ Share on other sites More sharing options...
MadTechie Posted May 19, 2009 Share Posted May 19, 2009 What are you asking ? how to format the menu or list it ? format = css list = SQL as this isn't the CSS section i'll assume you mean the SQL (not as if its the SQL section either) you could do this a few ways probably the easeist way is to do 2 queries, 1. SELECT * from MENU 2. SELECT * from subMenu WHERE menu=$menu then on your loop to create the Menu have an if statement to check if your at the submenu part ie (untested written on the fly) //$menuname = selected menu $SQL = "SELECT * from MENU" $menuq = mysql_query($SQL); while ($row = mysql_fetch_assc($menuq)) { echo $row['Name']; //menu item name if($row['Name'] == $menuname) { $sSQL = "SELECT * from SUBMENU WHERE MENU='$menuname' " $smenuq = mysql_query($sSQL); while ($srow = mysql_fetch_assc($smenuq )) { echo $srow['submenuname']; } } } Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-836900 Share on other sites More sharing options...
co.ador Posted May 19, 2009 Author Share Posted May 19, 2009 I meant the Sql formating. Thank you very much for clarifying that format = css and listing = sql i mean listing because I want it to display right now i just trying to get the logics of it and the funtion of the web page not the format and styling. so anything I post from now and on I want you to know it will mainly be about the Sql. I think i will be working on the listing and sql part of the web site for a while. Thank you again for teaching me the language of how to direct for help. That's very helpful because sometimes that could be big problem not knowing how to direct to you guys the more knowledgeable on the topic for help. I have been in other forums and because of not knowing how to direct to them is difficult for them to understand me. Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-836904 Share on other sites More sharing options...
co.ador Posted May 19, 2009 Author Share Posted May 19, 2009 i have another question madtechie. Below is the format part of the thumbnail with a query that call the subjects that i have decided to be the same ones in the <ul> list left of my page, very similar to the ones in the menu part in olivegarden.com/menus My question is around where in your code should I put the format part of the thumbnails. Below is the code that I have format around the thumbnails. and excuse my poor way of communication I am new. $sql = "SELECT menusubjects.Subject, menusubjects.image FROM menusubjects"; $result = mysql_query($sql, $connection); if(!$result){ die("Database query failed:" . mysql_error());} while ($content = mysql_fetch_array($result)) { echo "<table width="260\" height=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#FF0033\" bgcolor=\"#FFFFFF\" style=\"float:left; position:relative; left:206px; top: 300px; height:5px;\"> <td width=\"95%\ height=\"10%\"> <table width=\"96%\" height=\"10%\"> <td style=\"width:100%\"><img src=\"../images/lineforheader.gif\" alt=\"gf\" width=\"100%\" /></td><tr><td bordercolor=\"#666666\" bgcolor=\"#D83607\" height=\"100%\" style=\" width:140px;\"><a href=\"#\"> <div class=\"shoe2\" align=\"left\" style=\"background-image:url(../images/titleshoe.gif);\">" . $content['Subject'] . "</div> </a></td></tr> <tr> <td style=\"width:100%; background:#CC0000; height:2px;\"><a href=\"#\">" . $content['image'] . "</a></td> </tr></table></td> </table></td>"; } Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-836909 Share on other sites More sharing options...
MadTechie Posted May 19, 2009 Share Posted May 19, 2009 I'm sorry i don't get what your asking (it could also be me as its 4am here) am i correct in saying you want an image above some text and X number of columns if so your need to put only the second table in the loop. <?php $sql = "SELECT menusubjects.Subject, menusubjects.image FROM menusubjects"; $result = mysql_query($sql, $connection); if(!$result){ die("Database query failed:" . mysql_error());} echo "<table width=\"260\" height=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#FF0033\" bgcolor=\"#FFFFFF\" style=\"float:left; position:relative; left:206px; top: 300px; height:5px;\"> <td width=\"95%\ height=\"10%\">"; while ($content = mysql_fetch_array($result)) { echo "<table width=\"96%\" height=\"10%\"> <td style=\"width:100%\"><img src=\"../images/lineforheader.gif\" alt=\"gf\" width=\"100%\" /></td><tr><td bordercolor=\"#666666\" bgcolor=\"#D83607\" height=\"100%\" style=\" width:140px;\"><a href=\"#\"> <div class=\"shoe2\" align=\"left\" style=\"background-image:url(../images/titleshoe.gif);\">" . $content['Subject'] . "</div> </a></td></tr> <tr> <td style=\"width:100%; background:#CC0000; height:2px;\"><a href=\"#\">" . $content['image'] . "</a></td> </tr></table></td>"; } echo "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-836913 Share on other sites More sharing options...
co.ador Posted May 19, 2009 Author Share Posted May 19, 2009 Brother you are a good resource for me and I don't want to get you tired. I have a poor language which makes it difficult for me to display in your head what I want to achieve but I know it will be ok i just have to think a little bit more and try to figure out a better way to present you what I want to achieve. I will be re factoring a clear request through the night so you can understand and analyze it tomorrow. The queries you formed earlier will serve for this purpose but I don't know how to use and where to locate it in the file. I will have a clearer request formed by tomorrow morning. I hope you can check it out. I feel a little frustrated since I have been trying to put together this effect that appear in the above olive garden web site link. Now it's been some days and some late night going to bed. Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-836932 Share on other sites More sharing options...
co.ador Posted May 19, 2009 Author Share Posted May 19, 2009 The thumbnails are working good, They are formatted in a table and through the query the data from the Subject and image field are being display and looped within this formatted table(css ). Both the Subject and image field have a link tag wrap around them which right now this links are empty because I don’t know where to go from there. I have set up the webpage in two parts: 1. A <ul> list 2. A format thumbnail table. Part 1 of the web page has a <ul> list which I want only to display its submenus if the link for the Subject field in the thumbnail format table is cliked on. This is how the link tags look like around the Subject field in the thumbnail. <a href=\"#\"> <div class=\"shoe2\" align=\"left\" style=\"background-image:url(../images/titleshoe.gif);\">" . $content['Subject'] . "</div> </a> The first part of the web page is shown below and it displays an <Ul> list of subjects in the left of the page. These subjects are the same subjects pulled in the Thumbnail from the Subject field of the table menusubjects used in the Thumbnails query. This query display a list of subjects $sql = 'SELECT id,Subject FROM menusubjects;'; $result = mysql_query($sql); if($result && mysql_num_rows($result)!=0) { echo '<ul id="nav-categories">'; while($row = mysql_fetch_assoc($result)) { $uri = 'example1.php?subject='.urlencode($row['id']); $class = !is_null($cat) && $cat==$row['id']?' class="selected"':''; echo "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>'; if($submenu==false && !is_null($cat) && $cat == $row['id']) { This query display a list of submenus under the subjects : $sql2 = 'SELECT id,shoename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';'; $result2 = mysql_query($sql2); if($result2 && mysql_num_rows($result2)!=0) { echo "\n\t\t",'<ul class="submenu">',"\n"; while($row2 = mysql_fetch_assoc($result2)) { $uri2 = $uri.'&menu='.urlencode($row2['id']); $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':''; echo "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['shoename'],'</a></li>',"\n"; } echo "\t\t",'</ul> <!-- end of ul.submenu -->',"\n"; } $submenu = true; } echo '</li>',"\n"; } echo '</ul> <!-- end of ul#nav-categories -->',"\n The query for the submenus will only display if the fallowing statement if met: if($submenu==false && !is_null($cat) && $cat == $row['id']) { The entire<ul><li> subject and submenus list together would look as fallow: $sql = 'SELECT id,Subject FROM menusubjects;'; $result = mysql_query($sql); if($result && mysql_num_rows($result)!=0) { echo '<ul id="nav-categories">'; while($row = mysql_fetch_assoc($result)) { $uri = 'example1.php?subject='.urlencode($row['id']); $class = !is_null($cat) && $cat==$row['id']?' class="selected"':''; echo "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>'; if($submenu==false && !is_null($cat) && $cat == $row['id']) { ]$sql2 = 'SELECT id,shoename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';'; $result2 = mysql_query($sql2); if($result2 && mysql_num_rows($result2)!=0) { echo "\n\t\t",'<ul class="submenu">',"\n"; while($row2 = mysql_fetch_assoc($result2)) { $uri2 = $uri.'&menu='.urlencode($row2['id']); $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':''; echo "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['shoename'],'</a></li>',"\n"; } echo "\t\t",'</ul> <!-- end of ul.submenu -->',"\n"; } $submenu = true; } echo '</li>',"\n"; } echo '</ul> <!-- end of ul#nav-categories -->',"\n Thumbnails part. The thumbnails have a text on top pulled from a query call menusubjects. The query would look like this. $sql = "SELECT menusubjects.Subject, menusubjects.image FROM menusubjects"; $result = mysql_query($sql, $connection); if(!$result){ die("Database query failed:" . mysql_error());} Then the Subject field from the table menusubjects is put in within the thumbnail table format like this: <div class=\"shoe2\" align=\"left\" style=\"background-image:url(../images/titleshoe.gif);\">" . $content['Subject'] . "</div> Then the image field from the table menusubjects is put in within the thumbnail table format as well like this: <td style=\"width:100%; background:#CC0000; height:2px;\"><a href=\"#\">" . $content['image'] . "</a></td> For your reference betyon the entire Thumbnail table format would look like: "<table width="260" height=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#FF0033\" bgcolor=\"#FFFFFF\" style=\"float:left; position:relative; left:206px; top: 300px; height:5px;\"> <td width=\"95%\ height=\"10%\"> <table width=\"96%\" height=\"10%\"> <td style=\"width:100%\"><img src=\"../images/lineforheader.gif\" alt=\"gf\" width=\"100%\" /></td><tr><td bordercolor=\"#666666\" bgcolor=\"#D83607\" height=\"100%\" style=\" width:140px;\"><a href=\"#\"> <div class=\"shoe2\" align=\"left\" style=\"background-image:url(../images/titleshoe.gif);\">" . $content['Subject'] . "</div> </a></td></tr> <tr> <td style=\"width:100%; background:#CC0000; height:2px;\"><a href=\"#\">" . $content['image'] . "</a></td> </tr></table></td> </table></td>"; Now in the thumbnail table format part there are two links one for the Subjects Field and another for the image field. The link for the Subject field looks like this and can be found in the thumbnail table format above: <a href=\"#\"> <div class=\"shoe2\" align=\"left\" style=\"background-image:url(../images/titleshoe.gif);\">" . $content['Subject'] . "</div> </a> The other link assigned for the image field looks like this and can be found in the thumbnail table format above too: <td style=\"width:100%; background:#CC0000; height:2px;\"><a href=\"#\">" . $content['image'] . "</a></td> My question wrap a code that permits me to click on the thumbnail Subject field and then link me to page where you will find and see all the submenus displayed underneath the subject in the <ul> list, just by click on the thumbnail Subject field which will be the equivalent of <ul> <li>Subject field. Remember that the Thumbnail and the <ul> has the same field assigned, the Subject field from the menusubject table. Both use the same query and both call subjects. Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-836959 Share on other sites More sharing options...
co.ador Posted May 19, 2009 Author Share Posted May 19, 2009 You may notice this message is repeated but this one is edit and the other not! The thumbnails are working good, They are formatted in a table and through the query the data from the Subject and image field are being display and looped within this formatted table(css ). Both the Subject and image field have a link tag wrap around them which right now this links are empty because I don’t know where to go from there. I have set up the webpage in two parts: 1. A <ul> list 2. A format thumbnail table. Part 1 of the web page the <ul> list which I want only to display its submenus if the link for the Subject field in the thumbnail format table is cliked on by a user. This is how the link tags look like around the Subject field in the thumbnail. <a href=\"#\"> <div class=\"shoe2\" align=\"left\" style=\"background-image:url(../images/titleshoe.gif);\">" . $content['Subject'] . "</div> </a> First part of the Web Page the <ul> this part of the web page is shown below and it displays an <Ul> list of subjects in the left of the page. These subjects are the same subjects pulled in the Thumbnail from the Subject field of the table menusubjects used in the Thumbnails query. I have a query for each one, one for the <ul> and another for the thumbnails and both SELECT Subject FROM menusubjects. I don't know if I should use one instead.. The following query display a list of subjects in the first part of the web page the <ul> $sql = 'SELECT id,Subject FROM menusubjects;'; $result = mysql_query($sql); if($result && mysql_num_rows($result)!=0) { echo '<ul id="nav-categories">'; while($row = mysql_fetch_assoc($result)) { $uri = 'example1.php?subject='.urlencode($row['id']); $class = !is_null($cat) && $cat==$row['id']?' class="selected"':''; echo "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>'; if($submenu==false && !is_null($cat) && $cat == $row['id']) { This query display a list of submenus under the subjects in the <ul> part of the web page : $sql2 = 'SELECT id,shoename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';'; $result2 = mysql_query($sql2); if($result2 && mysql_num_rows($result2)!=0) { echo "\n\t\t",'<ul class="submenu">',"\n"; while($row2 = mysql_fetch_assoc($result2)) { $uri2 = $uri.'&menu='.urlencode($row2['id']); $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':''; echo "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['shoename'],'</a></li>',"\n"; } echo "\t\t",'</ul> <!-- end of ul.submenu -->',"\n"; } $submenu = true; } echo '</li>',"\n"; } echo '</ul> <!-- end of ul#nav-categories -->',"\n The query for the submenus will only display if the fallowing statement if met: if($submenu==false && !is_null($cat) && $cat == $row['id']) { For further reference the entire<ul><li> subject and submenus list together would look as fallow: $sql = 'SELECT id,Subject FROM menusubjects;'; $result = mysql_query($sql); if($result && mysql_num_rows($result)!=0) { echo '<ul id="nav-categories">'; while($row = mysql_fetch_assoc($result)) { $uri = 'example1.php?subject='.urlencode($row['id']); $class = !is_null($cat) && $cat==$row['id']?' class="selected"':''; echo "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>'; if($submenu==false && !is_null($cat) && $cat == $row['id']) { ]$sql2 = 'SELECT id,shoename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';'; $result2 = mysql_query($sql2); if($result2 && mysql_num_rows($result2)!=0) { echo "\n\t\t",'<ul class="submenu">',"\n"; while($row2 = mysql_fetch_assoc($result2)) { $uri2 = $uri.'&menu='.urlencode($row2['id']); $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':''; echo "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['shoename'],'</a></li>',"\n"; } echo "\t\t",'</ul> <!-- end of ul.submenu -->',"\n"; } $submenu = true; } echo '</li>',"\n"; } echo '</ul> <!-- end of ul#nav-categories -->',"\n end of the First part of the web page. Second part Thumbnail table. The thumbnails have a text on top pulled from a query call menusubjects as well. The query for the thumbnails and only one would look like this. $sql = "SELECT menusubjects.Subject, menusubjects.image FROM menusubjects"; $result = mysql_query($sql, $connection); if(!$result){ die("Database query failed:" . mysql_error());} Then the Subject field from the table menusubjects is put in, within the thumbnail table format and it looks like this: <div class=\"shoe2\" align=\"left\" style=\"background-image:url(../images/titleshoe.gif);\">" . $content['Subject'] . "</div> Then the image field from the table menusubjects is put in, within the thumbnail table format as well and it looks like this: <td style=\"width:100%; background:#CC0000; height:2px;\"><a href=\"#\">" . $content['image'] . "</a></td> For further reference the entire Thumbnail table format looks like this: "<table width="260" height=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#FF0033\" bgcolor=\"#FFFFFF\" style=\"float:left; position:relative; left:206px; top: 300px; height:5px;\"> <td width=\"95%\ height=\"10%\"> <table width=\"96%\" height=\"10%\"> <td style=\"width:100%\"><img src=\"../images/lineforheader.gif\" alt=\"gf\" width=\"100%\" /></td><tr><td bordercolor=\"#666666\" bgcolor=\"#D83607\" height=\"100%\" style=\" width:140px;\"><a href=\"#\"> <div class=\"shoe2\" align=\"left\" style=\"background-image:url(../images/titleshoe.gif);\">" . $content['Subject'] . "</div> </a></td></tr> <tr> <td style=\"width:100%; background:#CC0000; height:2px;\"><a href=\"#\">" . $content['image'] . "</a></td> </tr></table></td> </table></td>"; Now in the thumbnail table format part there are two links one for the Subjects Field and another for the image field. The link for the Subject field looks like this and can be found in the thumbnail table format above: <a href=\"#\"> <div class=\"shoe2\" align=\"left\" style=\"background-image:url(../images/titleshoe.gif);\">" . $content['Subject'] . "</div> </a> The other link assigned for the image field looks like this and can be found in the thumbnail table format above too: <td style=\"width:100%; background:#CC0000; height:2px;\"><a href=\"#\">" . $content['image'] . "</a></td> My question is how would look the wrapped code that permits the user to click on the thumbnail Subject field, which I imagine that will then link the user to a page where the user will find and see all the submenus displayed underneath the subject in the <ul> list, only when a user click on the thumbnail Subject field, which will be the equivalent of <ul> <li>Subject field. in other words I want a user is able to display the submenus in t he <ul> from the <ul> itself by clicking on a subject and by clicking on the thumbnail too; submenus will display downward or underneath the subject, by either clicking on one of the subjects of the <ul> or clicking on one of the subjects field in the looped thumbnails. Remember that the Thumbnail and the <ul> has the same field assigned, to accomodate users to choose from two options which either or will give users the same result, or will take to the same destination. hope I have been clear this time If not let me know. and again I apologize for any miss use of the language. Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-836965 Share on other sites More sharing options...
MadTechie Posted May 19, 2009 Share Posted May 19, 2009 okay i have created some simple sample code, for the menu, but used an array instead of an SQL Database <?php //Database start $MENU = array("Lunch","Dinner","Beverage"); $SubMenu = array( "Lunch" => array("Appetizers","Soups and Salads","Pizzas"), "Dinner" => array("Appetizers","Soups and Salads","Pizzas","Classic Recipes","Beef & Pork"), "Beverage" => array("Wines","Specialty Drinks","Beer","Other Beverages"), ); //Database end //ShowMenu echo "<UL>"; foreach($MENU as $m) { echo "<LI><a href=\"?menu=$m\">$m</a></LI>\n"; if(!empty($_GET['menu']) && $m == $_GET['menu']) { echo "<UL>"; foreach($SubMenu[$m] as $s) { echo "<LI>$s</LI>\n"; } echo "</UL>"; } } echo "</UL>"; ?> Heres a untested guess work at the SQL version, 9 used the above one as a base script <?php //ShowMenu echo "<UL>"; $result = mysql_query("SELECT id,Subject FROM menusubjects"); while($MENU = mysql_fetch_assoc($result)) { $m = $MENU['Subject']; $id = $MENU['id']; echo "<LI><a href=\"?menu=$id\">$m</a></LI>\n"; if(!empty($_GET['menu']) && $id == $_GET['menu']) { echo "<UL>"; $result2 = mysql_query("SELECT shoename FROM regularmenu WHERE menusubject_id=$id"); while($SubMenu = mysql_fetch_assoc($result2)) { $s = $SubMenu['shoename']; echo "<LI>$s</LI>\n"; } echo "</UL>"; } } echo "</UL>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-837536 Share on other sites More sharing options...
co.ador Posted May 20, 2009 Author Share Posted May 20, 2009 This ones work wonderful, The array and the SQL. We are close, I have created a file called menu2.php <?php //ShowMenu echo "<UL>"; $result = mysql_query("SELECT id,Subject FROM menusubjects"); while($MENU = mysql_fetch_assoc($result)) { $m = $MENU['Subject']; $id = $MENU['id']; echo "<LI><a href=\"?menu=$id\">$m</a></LI>\n"; if(!empty($_GET['menu']) && $id == $_GET['menu']) { echo "<UL>"; $result2 = mysql_query("SELECT shoename FROM regularmenu WHERE menusubject_id=$id"); while($SubMenu = mysql_fetch_assoc($result2)) { $s = $SubMenu['shoename']; echo "<LI>$s</LI>\n"; } echo "</UL>"; } } echo "</UL>"; ?> <?php $sql = "SELECT menusubjects.Subject, menusubjects.image FROM menusubjects "; $result = mysql_query($sql, $connection); if(!$result){ die("Database query failed:" . mysql_error());} while ($content = mysql_fetch_array($result)) { $uri3 = "menu2.php?manu_type=".urlencode($content['Subject']); echo "<table width=\"260\" height=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#FF0033\" bgcolor=\"#FFFFFF\" style=\"float:left; position:relative; left:206px; top: 300px; height:5px;\"> <td width=\"95%\ height=\"10%\"> <table width=\"96%\" height=\"10%\"> <td style=\"width:100%\"><img src=\"../images/lineforheader.gif\" alt=\"gf\" width=\"100%\" /></td><tr><td bordercolor=\"#666666\" bgcolor=\"#D83607\" height=\"100%\" style=\" width:140px;\"><a href=\"$uri3\"> <div class=\"letras2\" align=\"left\" style=\"background-image:url(../images/titleplate.gif);\">" . $content['Subject'] . "</div> </a></td></tr> <tr> <td style=\"width:100%; background:#CC0000; height:2px;\"><a href=\"#\"><img src=\"../images/chefrecommendation.gif\" alt=\"uy\ width=\"50%\" height=\"160\" /></a></td> </tr></table></td> </table></td>"; } ?> This menu.php has a thumbnail format table at the bottom which looks like this. <?php $sql = "SELECT menusubjects.Subject, menusubjects.image FROM menusubjects "; $result = mysql_query($sql, $connection); if(!$result){ die("Database query failed:" . mysql_error());} while ($content = mysql_fetch_array($result)) { $uri3 = "example2.php?menu_type=".urlencode($content['Subject']); echo "<table width=\"260\" height=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#FF0033\" bgcolor=\"#FFFFFF\" style=\"float:left; position:relative; left:206px; top: 300px; height:5px;\"> <td width=\"95%\ height=\"10%\"> <table width=\"96%\" height=\"10%\"> <td style=\"width:100%\"><img src=\"../images/lineforheader.gif\" alt=\"gf\" width=\"100%\" /></td><tr><td bordercolor=\"#666666\" bgcolor=\"#D83607\" height=\"100%\" style=\" width:140px;\"><a href=\"$uri3\"> <div class=\"letras2\" align=\"left\" style=\"background-image:url(../images/titleplate.gif);\">" . $content['Subject'] . "</div> </a></td></tr> <tr> <td style=\"width:100%; background:#CC0000; height:2px;\"><a href=\"#\"><img src=\"../images/chefrecommendation.gif\" alt=\"uy\ width=\"50%\" height=\"160\" /></a></td> </tr></table></td> </table></td>"; } ?> It queries the subjects and images from the menusubject table which are the same subject values displayed in the $MENU variable you created in the SQL version menu or the Array one. if you notice after the query I have a put a variable called $uri3, which contain a string "example2.php?menu_type=" with an urlencode value that will be passed to be used to display the submenus of the subjects in the example2.php when clicked on a thumbnails found in the menu2.php file. The value of the Thumbnails is ['Subject'] equal to the value of the $m = $MENU['Subject']; variable in the sql query in example2.php which you created in the Sql version menu. I have called your version example2.php. what type of comparison would be appropriate to place in the SQL menu version you did called by me example2.php? to display the submenus in the example2.php file through the value ['Subject'] being passed from menu2.php by clicking on the thumbnails. The url string would look like http://localhost/nyhungry/restaurants/menu2.php?menu_type=Regular+Menu now you are in example2.php file and all the submenus of the Regular+Menu in this case display underneath the subjects because of a comparison in the SQL menu version you did, Which I imagine to be in between the $MENU and the $SubMenu. Help Please this is what I have been trying to achieve all this days. Give me a hand MadTechie Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-837845 Share on other sites More sharing options...
co.ador Posted May 20, 2009 Author Share Posted May 20, 2009 I was wondering that instead of using menu2.php to example2.php i could use menu2.php to menu2.php Would that be possible? Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-837861 Share on other sites More sharing options...
MadTechie Posted May 20, 2009 Share Posted May 20, 2009 if your using menu2.php then this $uri3 = "example2.php?menu_type=".urlencode($content['Subject']); should be $uri3 = "menu2.php?menu=".urlencode($content['Subject']); Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-838009 Share on other sites More sharing options...
co.ador Posted May 20, 2009 Author Share Posted May 20, 2009 MAdTechie I tried like that but still the value of menu= is not passing to the menu page again to be used to open the subject of the respective menu= value coming from the previous page to open it automatically. Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-838062 Share on other sites More sharing options...
MadTechie Posted May 20, 2009 Share Posted May 20, 2009 can you post both pages in code tags (the # button) and i'll take a look (might have to wait until i leave work ) Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-838145 Share on other sites More sharing options...
co.ador Posted May 20, 2009 Author Share Posted May 20, 2009 Before I post anything I want to tell you I was reading about $_SESSION which it passes a variables value from one file to another. I image that is for the scripter to have it available to use that value. Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-838156 Share on other sites More sharing options...
MadTechie Posted May 20, 2009 Share Posted May 20, 2009 Sessions are used for passing from script to script, they are basically server side cookies however, POST + GET are use for getting data from the form! Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-838160 Share on other sites More sharing options...
co.ador Posted May 20, 2009 Author Share Posted May 20, 2009 Sessions are used for passing from script to script, both script need to be in the file? or it can be one in one file and another file right? for example: Page one called menu2.php <?php // First Part // $sql = 'SELECT id,Subject FROM menusubjects;'; $result = mysql_query($sql); if($result && mysql_num_rows($result)!=0) { echo '<ul id="nav-categories">'; while($row = mysql_fetch_assoc($result)) { $uri = 'example1.php?subject='.urlencode($row['id']); $class = !is_null($cat) && $cat==$row['id']?' class="selected"':''; echo "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>'; if($submenu==false && !is_null($cat) && $cat == $row['id']) { // line 58 $sql2 = 'SELECT id,shoename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';'; $result2 = mysql_query($sql2); if($result2 && mysql_num_rows($result2)!=0) { echo "\n\t\t",'<ul class="submenu">',"\n"; while($row2 = mysql_fetch_assoc($result2)) { $uri2 = $uri.'&menu='.urlencode($row2['id']); $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':''; echo "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['shoename'],'</a></li>',"\n"; } echo "\t\t",'</ul> <!-- end of ul.submenu -->',"\n"; } $submenu = true; } echo '</li>',"\n"; } echo '</ul> <!-- end of ul#nav-categories -->',"\n "; } <?php // Thumbnails // $sql = "SELECT menusubjects.Subject, menusubjects.image FROM menusubjects "; $result = mysql_query($sql, $connection); if(!$result){ die("Database query failed:" . mysql_error());} while ($content = mysql_fetch_array($result)) { $uri3 = "example2.php?menu_type=".urlencode($content['Subject']); echo "<table width=\"260\" height=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#FF0033\" bgcolor=\"#FFFFFF\" style=\"float:left; position:relative; left:206px; top: 300px; height:5px;\"> <td width=\"95%\ height=\"10%\"> <table width=\"96%\" height=\"10%\"> <td style=\"width:100%\"><img src=\"../images/lineforheader.gif\" alt=\"gf\" width=\"100%\" /></td><tr><td bordercolor=\"#666666\" bgcolor=\"#D83607\" height=\"100%\" style=\" width:140px;\"><a href=\"$uri3\"> <div class=\"letras2\" align=\"left\" style=\"background-image:url(../images/titleplate.gif);\">" . $content['Subject'] . "</div> </a></td></tr> <tr> <td style=\"width:100%; background:#CC0000; height:2px;\"><a href=\"#\"><img src=\"../images/chefrecommendation.gif\" alt=\"uy\ width=\"50%\" height=\"160\" /></a></td> </tr></table></td> </table></td>"; } ?> page 2 called example2.php $sql = 'SELECT id,Subject FROM menusubjects;'; $result = mysql_query($sql); if($result && mysql_num_rows($result)!=0) { echo '<ul id="nav-categories">'; while($row = mysql_fetch_assoc($result)) { $uri = 'example1.php?subject='.urlencode($row['id']); $class = !is_null($cat) && $cat==$row['id']?' class="selected"':''; echo "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>'; if($submenu==false && !is_null($cat) && $cat == $row['id']) { // line 58 $sql2 = 'SELECT id,shoename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';'; $result2 = mysql_query($sql2); if($result2 && mysql_num_rows($result2)!=0) { echo "\n\t\t",'<ul class="submenu">',"\n"; while($row2 = mysql_fetch_assoc($result2)) { $uri2 = $uri.'&menu='.urlencode($row2['id']); $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':''; echo "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['shoename'],'</a></li>',"\n"; } echo "\t\t",'</ul> <!-- end of ul.submenu -->',"\n"; } $submenu = true; } echo '</li>',"\n"; } echo '</ul> <!-- end of ul#nav-categories -->',"\n $query = "SELECT shoe.shoename, shoe.price, shoe.moreinfo FROM shoe WHERE shoe_kind = ". (int) $_GET['shoe']; // $_GET value I extract it from the (isset) selection at the top of the code. This condition will show the content if the shoe_kind is == to $_GET value. I don't know if the query or purpose described above need a query to be place before this query or after this query and table found on this final part of my code. echo $query $result = mysql_query($query, $connection); while ($content = mysql_fetch_array($result)) { echo "<table style="float:left\"> <td width=\"150\" style=\"text-align:center;\">" . $row['shoename'] . "</td> <tr> <td height=\"100\" width=\"100\" style=\"position:relative;\"> <img src=\"../images/shoesname.jpg\" alt=\"sd\" width=\"97\" height=\"80\" border=\"1\" style=\"border-color:#FF6600;\" /> </td></tr> <tr> <td width=\"5\" height=\"21\" ></td><td>" . $row['price'] . "</td> </tr><td>" . $row['moreinfo'] . "</td> </table>"; } ?> I have a question? How many scripts are in menu2.php and example2.php. ? What I have as a definition of an script is a whole file for instant menu2.php is an script. Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-838188 Share on other sites More sharing options...
MadTechie Posted May 20, 2009 Share Posted May 20, 2009 Erm.. if thats the full script then wheres $cat being set ? Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-838209 Share on other sites More sharing options...
co.ador Posted May 20, 2009 Author Share Posted May 20, 2009 pardon me I didn't put the isset values on top Below is the isset values for both files. Both files are using the same set up on top. <?php $submenu = false; $cat = isset($_GET['subject']) && is_numeric($_GET['subject'])?$_GET['subject']:null; $prod = isset($_GET['menu']) && is_numeric($_GET['menu'])?$_GET['menu']:null; $menu_type = isset($_GET['menu_type']) && is_string($_GET['menu_type'])?$_GET['menu_type']:null; ?> Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-838214 Share on other sites More sharing options...
MadTechie Posted May 20, 2009 Share Posted May 20, 2009 OKay whats the problem your having ? Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-838234 Share on other sites More sharing options...
co.ador Posted May 20, 2009 Author Share Posted May 20, 2009 If you take a look at this line in the isset values on top of each document, then you will realize I haven't use it at all in the script. I haven't use any condition or comparison using this variable. $menu_type = isset($_GET['menu_type']) && is_string($_GET['menu_type'])?$_GET['menu_type']:null; I have it set on top because I want a comparison of the Subject field around the script of the SQL query for menusubjec table and the SQL query for regularmenu table in the first part of the script, WHERE the $menu_type variable Subject field value coming from the Thumbnail part of the script $uri3 = "example2.php?menu_type=".urlencode($content['Subject']); so that comparison causes to open the $cat variable Subject field value from the menusubject table in the First Part of the Script and its submenus or shoename as well in either file that we decide to choose menu2.php or example2.php to perform this effect. I want it to open the regularmenu shooname fields values, if the cookie Subject field values of the $menu_type variable implemented in the Thumbnail equals the value of the Subject field from the menusubject table on the first part of the Script let say of example2.php Now I don't know if only one page could be use to achieve all this instead of implementing the cookie value of $menu_type variable Subject field from menu2.php to example2.php and then in example2.php make a condition where the $menu_type Subject field value carried from the menu2.php is equal the Subject value from the menusubject in Part One of the script in example2.php or menu2.php if is possible to achieve the implementation back and forth in the same file. In the menu2.php the $menu_type Subject value could be use to open menu2.php again and implement this action in there instead of using example2.php? hope you get what I am saying Passing the value of $menu_type (Subject value in the thumbnail)use it to form a comparison to open the shoename field values underneath the Subject values on the First Part of the Script all just by clicking on the Thumbnail instead of clicking on the List at the left or <ul>. I want the users to be able to open the Menu to see the shoename field values listed underneath the Subject from either clicking on the Thumbnails or in the <ul> list since the Subject field values are going to be echo in the <ul> the First Part of the script and in the Thumbnails Part of the Script as well. So either or a users click on they will be directed to the same page. if clicked on the <ul> then the next page is going to displayed the shoename field values displayed underneath the Subjects and if clicked on the Thumbnails then the <ul> is going to display the shoename field values are going to be displayed underneath the Subjects as if a user have clicked on the <ul> Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-838255 Share on other sites More sharing options...
co.ador Posted May 21, 2009 Author Share Posted May 21, 2009 Post for the purpose of bring it to front and for any suggestion to bring my inquiries into the right direction. Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-838650 Share on other sites More sharing options...
co.ador Posted May 21, 2009 Author Share Posted May 21, 2009 Me in Sitepoint Forum I have been confuse even trying to make the intent understandable but it is simple. http://www.olivegarden.com/menus/ go to that link then you will see four thumbnails in the bottom which they has the same field values as in four of the field found in the unordered list to the left below the Our Menu. unordered list: Italian specials Lunch Dinner Beverage, to go menu Dessert pastries Garden fare salad Childrens kids Thumbnails at the bottom Lunch Menu -------- Dinner Menu -------- Beverage Menu ----- Dessert Menu When you click on one the Thumbnails, the next page that the users is linked to, the equivalent the field in the unordered list to the left of the page display or appear opened with the categories underneath that Field. In other words either link, the unordered list or the thumbnails link, will link the user to that page where the unordered list will appear opened and with the categories underneath that field displayed downward. how do I achieve that within the code you gave me before. By Oddz on sitepoint forum: Those links at the bottom merely go to the same url. Its really just that simple unless I'm missing something. For example, mouse over lunch then mouse over the lunch thumbnail at the bottom. If you do this you should see that both of those links go to following url: http://www.olivegarden.com/menus/lunch/. Now if your asking how to create dynamic a thumbnail menu similar to the one on olive garden then that is a separate question and problem entirely. Me in sitepoint forum Now the question is very simple what should I code so that the lunch URL display the lunch menu. because the code done for you so far has display the menu if I click on in the unordered list but not when I click from the thumbnail it won't display the unordered list. I think i need to create a new page where it has conditions or maybe a comparison WHERE it opens the menu set to the value being pass from the thumbnail of the previous URL, i am not sure. i am not sure if that's what I mean but it sound like it could be the problem here and probably dynamic thumbnails will solve the problem. I am looking forward to see how dynamics will fit. Dynamics might be the answer to this, the thing is when a person is new in a language then it's difficult to express the intention, which can be said different than any other language. Quote Link to comment https://forums.phpfreaks.com/topic/158682-thumbnail-linking-to-an-specific-position-to-a-looped/#findComment-838713 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.