Jump to content

Recommended Posts

I'm trying to pass php select option value to another page through url.but it's not working.please help me.

 

member.php

<?php
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("nordfxlk_member")or die(mysql_error());
$result = mysql_query("SELECT id,ugroup FROM ugroups"); 


?>


<select name='group' id='group' >
<?php 
while ($line = mysql_fetch_array($result)) {
echo '<option value=' . $line['ugroup'] . '>' . $line['ugroup'] . '</option>';


}?>
</select>
<a href="db_sql/add_group.php?ugroup=<?php echo $line['ugroup'] ;?>"> click</a> 

add_group.php

 

 

include('../limoconfig.php');
if(!isset($_SESSION['adminuserid']) )
{
header('Location:../index.php');
}
else
{ 


$ugroup = $_GET['ugroup'];
/*$id = $_GET['id'];*/


$acc_status = "update users set ugroup='".$ugroup."' where id=1931";


echo $acc_status;
$rate = db::getInstance()->exec($acc_status); 


header('Location:../test.php'); 


}
}

 

Values from input fields will only be sent if a form has been submitted.

 

So you need to wrap your <select> field in a form and then submit the form using a button example

<form action="add_group.php" method="get"> <!-- start form -->

<select name='group' id='group' >   <!-- dropdown input field -->
<?php 
while ($line = mysql_fetch_array($result)) {
echo '<option value=' . $line['ugroup'] . '>' . $line['ugroup'] . '</option>';


}?>
</select>
<input type="submit" value="Go" /> <!-- the submit button -->
</form>

Now in add_group.php you'd use $_GET['group'] to retrieve the submitted value.

 

You can do away with submit button and submit the form by applying onchange event handler to select field.

when user click on submit i want to pass php select option value to add_group.php .in add_group.php should update ugroup value according to that passed value.

i'v tryed your code.but it doesn't update table value. 

Edited by codex
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.