Jump to content

Recommended Posts

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 :

 

<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">ЈАЗИК</span>

<select name="Jazik" id="Jazik" style="width:25%;height:inherit" >

<option selected="selected" value="none"> </option>

<option value="me">Македонски-Англиски</option>

<option value="em">Англиски-Македонски</option>

<option value="md">Македонски-Германски</option>

<option value="dm">Германски-Македонски</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акедонски-Англиски </option>";}

else

{echo "<option value='me'> Mакедонски-Англиски </option>";} ?>

<?php if ($_POST["Jazik"] == "em"){echo "<option value='em' selected> Англиски-Македонски </option>";}

else

{echo "<option value='em'> Англиски-Македонски </option>";} ?>

<?php if ($_POST["Jazik"] == "md"){echo "<option value='md' selected> Македонски-Германски </option>";}

else

{echo "<option value='md'> Македонски-Германски </option>";} ?>

<?php if ($_POST["Jazik"] == "dm"){echo "<option value='dm' selected> Германски-Македонски </option>";}

else

{echo "<option value='dm'> Германски-Македонски </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 Smile ) 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";}}

 

 

the problem is that $_POST["Jazik"] works when displaying the selected value from prva.php in vtora.php(it remembers what was selected in prva.php) but in the code that is for choosing a database table when I do

$jazik=$_POST["Jazik"];

echo "$jazik";

it returns nothing- the variable $jazik is empty and I don't know why because the code for choosing a database table is also in the vtora.php script

 

Please give me ur valuables idea

Thanks

Link to comment
https://forums.phpfreaks.com/topic/55958-passing-value-from-a-drop-down-menu/
Share on other sites

if you use those page for same purpose try to just use php self

and what are this for again??

<?php

if ($_POST["Jazik"] == "none"){echo "<option value='none' selected> </option>";}?>

<?php if ($_POST["Jazik"] == "me"){echo "<option value='me' selected> Mакедонски-Англиски </option>";}

else

{echo "<option value='me'> Mакедонски-Англиски </option>";} ?>

<?php if ($_POST["Jazik"] == "em"){echo "<option value='em' selected> Англиски-Македонски </option>";}

else

{echo "<option value='em'> Англиски-Македонски </option>";} ?>

<?php if ($_POST["Jazik"] == "md"){echo "<option value='md' selected> Македонски-Германски </option>";}

else

{echo "<option value='md'> Македонски-Германски </option>";} ?>

<?php if ($_POST["Jazik"] == "dm"){echo "<option value='dm' selected> Германски-Македонски </option>";}

else

{echo "<option value='dm'> Германски-Македонски </option>";} ?>

</select>

</div>

</form>

 

sorry i just dont get your point

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.