chris8726 Posted August 21, 2007 Share Posted August 21, 2007 Hello. I am trying to create a persisting menu system. What I have are drop-down lists that appear when a value is selected from a main drop-down list. What I want to do is have the option selected persist as the menu system is moved through. If you would like to look at what I have so far you can go to <a href="http://www.rentalcityomaha.com/specialevent.php">www.rentalcityomaha.com</a>. I can get the first drop-down list to persist by using PHP because it is static, but the other menus are variable depending on the option selected by the first menu. These menus are written inside of an ECHO statement and I need them to have a PHP Statement within them. I will give you an example of what I have so far and what I am trying to do may look like. This is the main menu: <form action="specialevent.php" method="get" name="specialevent1" id="specialevent1"> Special Events & Parties: <br> <select name="specialevent1" id="specialevent1"> <option value="inflatable" <?PHP if (($_GET['specialevent1']) == "inflatable" or ($_GET['inflatable1']) or ($_GET ['spacewalk1'])) {echo "selected";} ?>>Inflatables</option> <option value="helium" <?PHP if (($_GET['specialevent1']) == "helium" or ($_GET['helium1'])) {echo "selected";} ?>>Helium</option> <option value="guest" <?PHP if (($_GET['specialevent1']) == "guest" or ($_GET['guest1']) or ($_GET['bed1']) or ($_GET['crib1'])) {echo "selected";} ?>>Guest Needs</option> <option value="concession" <?PHP if (($_GET['specialevent1']) == "concession" or ($_GET['concession1'])) {echo "selected";} ?>>Concession</option> <option value="avbus" <?PHP if (($_GET['specialevent1']) == "avbus" or ($_GET['avbus1']) or ($_GET['projector1']) or ($_GET['pscreen1']) or ($_GET['pasystem1']) or ($_GET['television1'])) {echo "selected";} ?>>Audio Visual/Business</option> <option value="wedding" <?PHP if (($_GET['specialevent1']) == "wedding" or ($_GET['wedding1']) or ($_GET['candleabrab1']) or ($_GET['candleabras1']) or ($_GET['lattice1']) or ($_GET['arch1']) or ($_GET['weddingdec1']) or ($_GET['wedfountain1'])) {echo "selected";} ?>>Weddings</option> <option value="tablechair" <?PHP if (($_GET['specialevent1']) == "tablechair" or ($_GET['tablechair1']) or ($_GET['roundtable1']) or ($_GET['banqtable1']) or ($_GET['othertable1']) or ($_GET['chair1'])) {echo "selected";} ?>>Tables & Chairs</option> <option value="carnival" <?PHP if (($_GET['specialevent1']) == "carnival" or ($_GET['carnival1']) or ($_GET['carnivalgame1']) or ($_GET['misccarngame1']) or ($_GET['misccarnitem1'])) {echo "selected";} ?>>Carnival</option> <option value="casino" <?PHP if (($_GET['specialevent1']) == "casino" or ($_GET['casino1']) or ($_GET['casinogame1']) or ($_GET['slotmachine1']) or ($_GET['misccasino1'])) {echo "selected";} ?>>Casino</option> <option value="linenskirt" <?PHP if (($_GET['specialevent1']) == "linenskirt" or ($_GET['linenskirt1']) or ($_GET['linen1']) or ($_GET['skirt1']) or ($_GET['misclin1'])) {echo "selected";} ?>>Linens & Skirting</option> <option value="bar" <?PHP if (($_GET['specialevent1']) == "bar" or ($_GET['bar1'])) {echo "selected";} ?>>Bars</option> <option value="beverageservice" <?PHP if (($_GET['specialevent1']) == "beverageservice" or ($_GET['beverageservice1']) or ($_GET['punchservice1']) or ($_GET['coffeeservice1']) or ($_GET['bevfoutain1'])) {echo "selected";} ?>>Beverage Service</option> <option value="dancefloor" <?PHP if (($_GET['specialevent1']) == "dancefloor" or ($_GET['dancefloor1']) or ($_GET['woodfloor1'])) {echo "selected";} ?>>Dance Floors</option> <option value="chinaflatware" <?PHP if (($_GET['specialevent1']) == "chinaflatware" or ($_GET['chinaflatware1']) or ($_GET['china1']) or ($_GET['glassstem1']) or ($_GET['chinaflatware1'])) {echo "selected";} ?>>China & Flatware</option> <option value="chaferroaster" <?PHP if (($_GET['specialevent1']) == "chaferroaster" or ($_GET['chaferroaster1']) or ($_GET['stainlesschafer1']) or ($_GET['goldtrimchafer1'])) {echo "selected";} ?>>Chafers & Roasters</option> <option value="canopytent" <?PHP if (($_GET['specialevent1']) == "canopytent" or ($_GET['canopytent1']) or ($_GET['partycanopy1']) or ($_GET['frametent1'])) {echo "selected";} ?>>Tents & Canopies</option> <option value="grill" <?PHP if (($_GET['specialevent1']) == "grill" or ($_GET['grill1'])) {echo "selected";} ?>>Grills</option> <option value="centerpiece" <?PHP if (($_GET['specialevent1']) == "centerpiece" or ($_GET['centerpiece1']) or ($_GET['bubblebowl1']) or ($_GET['centerpiecemisc1'])) {echo "selected";} ?>>Center Pieces</option> <option value="decoration" <?PHP if (($_GET['specialevent1']) == "decoration" or ($_GET['decoration1']) or ($_GET['tree1']) or ($_GET['column1']) or ($_GET['fence1']) or ($_GET['hawaiian1']) or ($_GET['decomisc1'])) {echo "selected";} ?>>Decorations</option> <option value="cooler" <?PHP if (($_GET['specialevent1']) == "cooler" or ($_GET['cooler1']) or ($_GET['keghold1']) or ($_GET['drinkserv1']) or ($_GET['dispenser1']) or ($_GET['drinkcooler1'])) {echo "selected";} ?>>Drink Dispensers & Coolers</option> <option value="light" <?PHP if (($_GET['specialevent1']) == "light" or ($_GET['lighting1']) or ($_GET['lightdeco1']) ) {echo "selected";} ?>>Lighting</option> <option value="misc" <?PHP if (($_GET['specialevent1']) == "misc" or ($_GET['misc1']) or ($_GET['stanchion1'])) {echo "selected";} ?>>Miscellaneous</option> </select> <input type="submit" id="eventbutton" value="Submit"> </form> After you select on of the options from that menu a new menu appears and the old menu holds it's value. But when you select a value from the second menu the frist menu still persists, but the second menu reverts to it's basic default option (top of the list). Here is a look at one of the second menus that appear: <?php if (($_GET['specialevent1']) == "helium" or ($_GET['helium1'])) { echo "<form action=\"specialevent.php?specialevent1=helium\" method=\"get\" name=\"helium1\" id=\"helium1\"> Helium:<br> <select name=\"helium1\" id=\"helium1\"> <option value=\"helilarge\">Large Helium Tank</option> <option value=\"helismall\">Small Helium Tank</option> </select> <input type=\"submit\" id=\"heliumbutton\" value=\"Submit\"> </form>"; } ?> What I can't get to work is this: <?php if (($_GET['specialevent1']) == "helium" or ($_GET['helium1'])) { echo "<form action=\"specialevent.php?specialevent1=helium\" method=\"get\" name=\"helium1\" id=\"helium1\"> Helium:<br> <select name=\"helium1\" id=\"helium1\"> <option value=\"helilarge\" <?PHP if ($_GET['helium1']) == \"helilarge\" {echo \"selected\";} ?>>Large Helium Tank</option> <option value=\"helismall\" <?PHP if ($_GET['helium1']) == \"helilarge\" {echo \"selected\";} ?>>Small Helium Tank</option> </select> <input type=\"submit\" id=\"heliumbutton\" value=\"Submit\"> </form>"; } ?> It won't run that PHP script within an echo statement and I really don't know why. Most likely I'm doing it wrong, but I don't know how else to do it. If anyone has any suggestions I'd appreciate it. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/66062-php-statement-within-an-echo-statement/ Share on other sites More sharing options...
trq Posted August 21, 2007 Share Posted August 21, 2007 <?php if (($_GET['specialevent1']) == "helium" or ($_GET['helium1'])) { echo " <form action=\"specialevent.php?specialevent1=helium\" method=\"get\" name=\"helium1\" id=\"helium1\">Helium: <select name=\"helium1\" id=\"helium1\"> <option value=\"helilarge\"" . ($_GET['helium1'] == 'helilarge') ? "'selected'" : '' . ">Large Helium Tank</option> <option value=\"helismall\"" . ($_GET['helium1'] == 'helilarge') ? "'selected'" : '' . ">Small Helium Tank</option> </select> <input type=\"submit\" id=\"heliumbutton\" value=\"Submit\"> </form>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/66062-php-statement-within-an-echo-statement/#findComment-330403 Share on other sites More sharing options...
chris8726 Posted August 22, 2007 Author Share Posted August 22, 2007 Thanks for the help, but it didn't quite fix the problem. When I put the suggested code into it's place and try to run my page all I get is 'selected' printed on the page instead of the menu that should be there. Here is what the script look like with the suggested code: <?php if (($_GET['specialevent1']) == "helium" or ($_GET['helium1'])) { echo " <form action=\"specialevent.php?specialevent1=helium\" method=\"get\" name=\"helium1\" id=\"helium1\"> Helium:<br> <select name=\"helium1\" id=\"helium1\"> <option value=\"helilarge\"" . ($_GET['helium1'] == 'helilarge') ? "'selected'" : '' . ">Large Helium Tank</option> <option value=\"helismall\"" . ($_GET['helium1'] == 'helismall') ? "'selected'" : '' . ">Small Helium Tank</option> </select> <input type=\"submit\" id=\"heliumbutton\" value=\"Submit\"> </form>"; } ?> Anyone have any further suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/66062-php-statement-within-an-echo-statement/#findComment-330885 Share on other sites More sharing options...
trq Posted August 22, 2007 Share Posted August 22, 2007 Try... <?php if (($_GET['specialevent1']) == "helium" or ($_GET['helium1'])) { echo " <form action=\"specialevent.php?specialevent1=helium\" method=\"get\" name=\"helium1\" id=\"helium1\">Helium: <select name=\"helium1\" id=\"helium1\"> <option value=\"helilarge\"" . (($_GET['helium1'] == 'helilarge') ? " selected='selected'" : '') . ">Large Helium Tank</option> <option value=\"helismall\"" . (($_GET['helium1'] == 'helilarge') ? " selected='selected'" : '') . ">Small Helium Tank</option> </select> <input type=\"submit\" id=\"heliumbutton\" value=\"Submit\"> </form>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/66062-php-statement-within-an-echo-statement/#findComment-330937 Share on other sites More sharing options...
chris8726 Posted August 22, 2007 Author Share Posted August 22, 2007 Thanks thorpe it looks like that worked. I really appreciate your help. I spent so much time busting my head trying to figure that out. It feels real good not to have to worry about it anymore. Quote Link to comment https://forums.phpfreaks.com/topic/66062-php-statement-within-an-echo-statement/#findComment-330982 Share on other sites More sharing options...
$username Posted August 22, 2007 Share Posted August 22, 2007 Don't forget to mark the post as Solved. Brett Quote Link to comment https://forums.phpfreaks.com/topic/66062-php-statement-within-an-echo-statement/#findComment-330988 Share on other sites More sharing options...
chris8726 Posted August 22, 2007 Author Share Posted August 22, 2007 Well, I thought I had it solved. I ran into one more problem though. That problem is in some cases I need the menu option to stick for more than one option, by using 'or' statements. You can see use of them in the original post. They work fine on the first menu but in the forthcoming menus only options without an 'or' statement work. Here is the code I am trying to add the 'or' statement to: <?php if (($_GET['specialevent1']) == "guest" or ($_GET['guest1']) or ($_GET['bed1']) or ($_GET['crib1'])) { echo "<form action=\"specialevent.php?specialevent1=guest\" method=\"get\" name=\"guest1\" id=\"guest1\"> Guest Needs:<br> <select name=\"guest1\" id=\"guest1\"> <option value=\"bed\"" . (($_GET['guest1'] == 'bed') or ($_GET['bed1']) ? " selected='selected'" : '') . ">Beds</option> <option value=\"crib\"" . (($_GET['guest1'] == 'crib') or ($_GET['crib1']) ? " selected='selected'" : '') . ">Cribs</option> <option value=\"playpen\"" . (($_GET['guest1'] == 'playpen') ? " selected='selected'" : '') . ">Playpens</option> <option value=\"boosterseat\"" . (($_GET['guest1'] == 'boosterseat') ? " selected='selected'" : '') . ">Booster Seats</option> <option value=\"highchair\"" . (($_GET['guest1'] == 'highchair') ? " selected='selected'" : '') . ">High Chairs</option> <option value=\"carseat\"" . (($_GET['guest1'] == 'carseat') ? " selected='selected'" : '') . ">Car Seats</option> <option value=\"stroller\"" . (($_GET['guest1'] == 'stroller') ? " selected='selected'" : '') . ">Strollers</option> <option value=\"crutch\"" . (($_GET['guest1'] == 'crutch') ? " selected='selected'" : '') . ">Crutches</option> <option value=\"walker\"" . (($_GET['guest1'] == 'walker') ? " selected='selected'" : '') . ">Walkers</option> <option value=\"wheelchair\"" . (($_GET['guest1'] == 'wheelchair') ? " selected='selected'" : '') . ">Wheel Chairs</option> <option value=\"cane\"" . (($_GET['guest1'] == 'cane') ? " selected='selected'" : '') . ">Canes</option> </select> <input type=\"submit\" id=\"guestbutton\" value=\"Submit\"> </form>"; } ?> As you can see only the top two options require an 'or' statement. That is because only those two option bring up a sub menu of that category. If you have any ideas I'd love to see them. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/66062-php-statement-within-an-echo-statement/#findComment-331006 Share on other sites More sharing options...
chris8726 Posted August 23, 2007 Author Share Posted August 23, 2007 Still can't get it to work. I've been messing with ideas on it and I still can't get anything to change. Quote Link to comment https://forums.phpfreaks.com/topic/66062-php-statement-within-an-echo-statement/#findComment-331902 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.