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? Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/ 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. Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293850 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.. Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293855 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. Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293857 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. Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293858 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. Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293859 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. Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293862 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? Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293865 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. Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293869 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. Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293871 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) Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293873 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]"); } Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293876 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. Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293877 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> Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293878 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. Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293879 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!! Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293889 Share on other sites More sharing options...
Yesideez Posted July 9, 2007 Share Posted July 9, 2007 Glad it's sorted Link to comment https://forums.phpfreaks.com/topic/59165-solved-how-are-these-data-types-returned/#findComment-293892 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.