values in drop down menu

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jylaj
Forum Newbie
Posts: 2
Joined: Thu Jun 07, 2007 5:45 pm

values in drop down menu

Post by jylaj »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi,

I am having dropdown menu in my php script(prva.php). In another php script (vtora.php) I have the same drop down menu but the drop down menu shows the previously selected value from the drop down menu in prva.php(from the various values that are optional to select).
The problem that I have is that I want depending on the value from the drop down menu that was passed to vtora.php to select a table from my database.

The code for the drop down menu in prva.php is :

Code: Select all

<form name="Meni" action="vtora.php" method="POST">

<tr>
<td width="44%" align="center" valign="top" bordercolor="#00FFFF" class="A-Text-BG" id="Recnik11_Td4">
<div align="right">
<p><span class="style5">&#1032;&#1040;&#1047;&#1048;&#1050;</span>
<select name="Jazik" id="Jazik" style="width:25%;height:inherit" >
<option selected="selected" value="none"> </option>
<option value="me">&#1052;&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080;-&#1040;&#1085;&#1075;&#1083;&#1080;&#1089;&#1082;&#1080;</option>
<option value="em">&#1040;&#1085;&#1075;&#1083;&#1080;&#1089;&#1082;&#1080;-&#1052;&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080;</option>
<option value="md">&#1052;&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080;-&#1043;&#1077;&#1088;&#1084;&#1072;&#1085;&#1089;&#1082;&#1080;</option>
<option value="dm">&#1043;&#1077;&#1088;&#1084;&#1072;&#1085;&#1089;&#1082;&#1080;-&#1052;&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080;</option>
</select>
</p>
</div>
</td>
</tr>
</form>
<?php

The code for the drop down menu in vtora.php is :

<form method="post" action="vtora.php" >

<?php
if ($_POST["Jazik"] == "none"){echo "<option value='none' selected> </option>";}?>
<?php if ($_POST["Jazik"] == "me"){echo "<option value='me' selected> M&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080;-&#1040;&#1085;&#1075;&#1083;&#1080;&#1089;&#1082;&#1080; </option>";}
else
{echo "<option value='me'> M&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080;-&#1040;&#1085;&#1075;&#1083;&#1080;&#1089;&#1082;&#1080; </option>";} ?>
<?php if ($_POST["Jazik"] == "em"){echo "<option value='em' selected> &#1040;&#1085;&#1075;&#1083;&#1080;&#1089;&#1082;&#1080;-&#1052;&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080; </option>";}
else
{echo "<option value='em'> &#1040;&#1085;&#1075;&#1083;&#1080;&#1089;&#1082;&#1080;-&#1052;&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080; </option>";} ?>
<?php if ($_POST["Jazik"] == "md"){echo "<option value='md' selected> &#1052;&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080;-&#1043;&#1077;&#1088;&#1084;&#1072;&#1085;&#1089;&#1082;&#1080; </option>";}
else
{echo "<option value='md'> &#1052;&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080;-&#1043;&#1077;&#1088;&#1084;&#1072;&#1085;&#1089;&#1082;&#1080; </option>";} ?>
<?php if ($_POST["Jazik"] == "dm"){echo "<option value='dm' selected> &#1043;&#1077;&#1088;&#1084;&#1072;&#1085;&#1089;&#1082;&#1080;-&#1052;&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080; </option>";}
else
{echo "<option value='dm'> &#1043;&#1077;&#1088;&#1084;&#1072;&#1085;&#1089;&#1082;&#1080;-&#1052;&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080; </option>";} ?>
</select>
</div>
</form>

The code that I am using to select a table depending on the value that was passed to vtora.php(and that code doesn't seem to work  ) is :

if ($_POST["Jazik"]=="me") {$tabela="ang_mak";}
else
{if ($_POST["Jazik"]=="em") {$tabela="mak_ang";}}
if ($_POST["Jazik"]=="md") {$tabela="ger_mak";}
else
{if ($_POST["Jazik"]=="dm") {$tabela="mak_ger";}}
Please give me [s]ur[/s] your valuables idea
Thanks
Reply With Quote


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]11.[/b] Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.[/quote]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Is this directly related to your previous post?
Post Reply