codex Posted September 27, 2014 Share Posted September 27, 2014 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'); } } Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted September 27, 2014 Share Posted September 27, 2014 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. Quote Link to comment Share on other sites More sharing options...
codex Posted September 27, 2014 Author Share Posted September 27, 2014 (edited) i'v tryed it.but it doesn't work. Edited September 27, 2014 by codex Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted September 27, 2014 Share Posted September 27, 2014 What does "doesn't work" mean? It would be helpful if you told use what it is you are trying to do. Quote Link to comment Share on other sites More sharing options...
codex Posted September 27, 2014 Author Share Posted September 27, 2014 (edited) 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 September 27, 2014 by codex Quote Link to comment Share on other sites More sharing options...
fabiez Posted September 27, 2014 Share Posted September 27, 2014 It's cause you chose to get ugroup instead of what you named the select field. Wich is group Quote Link to comment 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.