Jump to content

[SOLVED] How are these data types returned?


clanstyles

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

<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
Share on other sites

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
Share on other sites

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.