clanstyles Posted July 9, 2007 Share Posted July 9, 2007 How is an html event like this returned? <select name="rank" size="6" id="rank" multiple="1"> <?php $result = mysql_query("SELECT * FROM `ranks`") or die(mysql_error()); while($res = mysql_fetch_array($result)) { if($res['rank'] != "Guest" || $res['rank'] != "Administrator") echo "<option value=\"0\">".$res['rank']."</option>"; } ?> </select> If i select one and do a print out $_post['rank']; its always blank. Whats up ? How do these types of things work? Quote Link to comment Share on other sites More sharing options...
per1os Posted July 9, 2007 Share Posted July 9, 2007 $_POST should be capitol and the value is what would be printed out. It should print "0" ...really no matter what as long as they aren't a guest or an admin. Quote Link to comment Share on other sites More sharing options...
clanstyles Posted July 9, 2007 Author Share Posted July 9, 2007 Well I added echo "hi"; it doesn't work eathier.... if(isset($_POST['Submit'])) isan't wokring.. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 You mean how do drop-down selection boxes work? First you define a list of options: <option value="X" selected="selected">Y</option> X would be a value unique to that option which is used to identify it. Y is the text that the user would see in the list The selected="selected" is only used once and tells the browser which one to display as default. This can be omitted and if it is, it'll use the very first as the default option. You can have as many of those options as you want. Once you've got the list made you need to surround them with some more HTML to activate them: <select name="N">O</select> N is th name which you use to identfy with $_POST or $_GET O is the list of options you just built above Hope that explains it well enough. Quote Link to comment Share on other sites More sharing options...
per1os Posted July 9, 2007 Share Posted July 9, 2007 Is display_Errors set to on via www.php.net/ini_set and error_reporting(E_ALL) It sounds like you have an error in your code. Try doing a print_r($_POST); at the top. Quote Link to comment Share on other sites More sharing options...
Carterhost Posted July 9, 2007 Share Posted July 9, 2007 while($res = mysql_fetch_array($result)) { if($res['rank'] != "Guest" || $res['rank'] != "Administrator") echo "<option value='"$res['rank']"'.>".$res['rank']."</option>"; } That will populate your $_POST['rank'] with the rank, as long as it's not Guest or Administrator. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 The case of "N" must be the same in both SELECT and $_POST/$_GET. If you use name="cats" and have $_POST['Cats'] then they won't be the same. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 1. In your FORM declaration are you using method="get" or method="post"? 2. What did you call your SUBMIT button and what have you called it in your $_POST/$_GET? Quote Link to comment Share on other sites More sharing options...
clanstyles Posted July 9, 2007 Author Share Posted July 9, 2007 K heres what I hav enow, btw post. if(isset($_POST['Submit'])) { echo sizeof($_POST['deleterank']); } ?> <form id="delrank" name="delrank" method="post" action="?page=accountarea&place=adminarea&action=delranks" enctype="multipart/form-data"> Rank Name(s): <label> <select name="deleterank" size="6" id="deleterank" multiple="0"> <?php $result = mysql_query("SELECT * FROM `ranks`") or die(mysql_error()); while($res = mysql_fetch_array($result)) { if($res['rank'] != "Guest" && $res['rank'] != "Administrator") echo "<option value=\"".$res['id']."\" id=\"rank\">".$res['rank']."</option>"; } ?> </select> </label> <p> <label> <input type="submit" name="Submit" id="Submit" value="Submit" /> </label> </p> </form> Now, I need to get lets say I click 3 at once. How do I get ALL three? It isan't puting them, into an array it just selects one. of the 2 i click or something like that. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 btw, if you right-click your browser and select "View source" you can see the HTML that your script has made and see what values the options have been given. Quote Link to comment Share on other sites More sharing options...
per1os Posted July 9, 2007 Share Posted July 9, 2007 This may be causing the problems enctype="multipart/form-data"> Unsure but try removing that and see if you still have a problem (do a print_r or a vardump on the $_POST) Quote Link to comment Share on other sites More sharing options...
clanstyles Posted July 9, 2007 Author Share Posted July 9, 2007 Removing the encrypt tag didn't work and also the print_r / var_dump only returns the one value. If you chose more than one it just returns hte last one.\ And yeah they show right. On click it is supposed to grab the ID so i can do for($i=0;$i<sizeof($array);$i++) { mysql_query("DELETE FROM `ranks` WHERE `id`=$array[$i]"); } Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 Can you show the HTML the script makes? Need to make sure you're actually getting values put in the options. If you're not it explains why you're not getting anything back. Quote Link to comment Share on other sites More sharing options...
clanstyles Posted July 9, 2007 Author Share Posted July 9, 2007 <form id="delrank" name="delrank" method="post" action="?page=accountarea&place=adminarea&action=delranks" enctype="multipart/form-data"> Rank Name(s): <label> <select name="deleterank" size="6" id="deleterank" multiple="1"> <option value="3">Member</option> <option value="4">Horde 10-60</option> <option value="5">Alliance 10-60</option> <option value="6">Horde and Alliance 10-60</option> <option value="7">Horde and Alliance 61-70</option> <option value="8">Horde 61-70</option> <option value="9">Alliance 61-70</option> <option value="10">Farm Profiles</option> <option value="11">Elite Profiles</option> </select> </label> <p> <label> <input type="submit" name="Submit" id="Submit" value="Submit" /> </label> </p> </form> Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 Change this line and try again: <select name="deleterank[]" size="6" id="deleterank" multiple="multiple"> EDIT:: btw, I made two changes. Quote Link to comment Share on other sites More sharing options...
clanstyles Posted July 9, 2007 Author Share Posted July 9, 2007 Change this line and try again: <select name="deleterank[]" size="6" id="deleterank" multiple="multiple"> EDIT:: btw, I made two changes. w00t thanks man that did it. deleterank[] ive had bad luck w/ that before <3 u so much. Thanks Bye!! Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 Glad it's sorted 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.