s_ainley87 Posted April 28, 2008 Share Posted April 28, 2008 Hi, This is probably really simple, I have this code, <form name="modCat" action="modCat.php" method="post"> <select name="categoryID"> <?php //let's get some data, and put it in a drop down $query= "SELECT category_id, category_name FROM category ". "ORDER BY category_name"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { //disply the menu echo "<option value=\"".$row['category_id']."\">".$row['category_name']."\n"; } ?> </select> <input type="submit" name="subModCat" value="Submit" /> </form> As you can see it is creating a drop down menu that gets populated by category_names, the next chain of events if that the user click submit and get directed to a new page where they will fill out a form, I am wanting the form to all ready hold the category name they just selected but cannot find the $_POST that holds it can some help me please? Link to comment https://forums.phpfreaks.com/topic/103304-getting-the-_postvariable/ Share on other sites More sharing options...
kenrbnsn Posted April 28, 2008 Share Posted April 28, 2008 That would be in $_POST['categoryID'] Whenever you want to see what is being passed to your script, put <?php echo '<pre>' . print_r($_POST,true) . '</pre>'; ?> at the start of your script. This will dump that $_POST array. Ken Link to comment https://forums.phpfreaks.com/topic/103304-getting-the-_postvariable/#findComment-529085 Share on other sites More sharing options...
s_ainley87 Posted April 28, 2008 Author Share Posted April 28, 2008 i used your suggestion and it just echos the category_id, could you sugest something else? Link to comment https://forums.phpfreaks.com/topic/103304-getting-the-_postvariable/#findComment-529097 Share on other sites More sharing options...
Xorandnotor Posted April 28, 2008 Share Posted April 28, 2008 while($row = mysql_fetch_array($result)) { //disply the menu echo "<option value=\"".$row['category_id']; if ($_POST['categoryID'] == $row['category_id']) echo " SELECTED"; echo "\" />".$row['category_name']."\n"; } Link to comment https://forums.phpfreaks.com/topic/103304-getting-the-_postvariable/#findComment-529099 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.