Jump to content

[SOLVED] Drop Down Menu -> Mysql


icez

Recommended Posts

Hey, I'm trying to add data from a drop down menu into my database... But What I did does not work.

 

<?php
if(isset($_POST['save']))
{
   $itemn   = $_POST['itemn'];
   $realm = $_POST["realm"];

   if(!get_magic_quotes_gpc())
   {
      $itemn   = addslashes($itemn);
   }

   $query = " INSERT INTO items (itemn, realm) ".
            " VALUES ('$itemn, '$realm')";
   mysql_query($query) or die('Error ,query failed');

   echo "'$itemn' on '$realm' added";
}
?>
<form method="post">
<table width="700" border="0" cellpadding="2" cellspacing="1" align="center">
<tr>
<td width="100">Item Name</td>
<td><input name="itemn" type="text"></td>
</tr>
<tr>
<td width="100">Realm</td>
<td>


<select name="realm">
    <option value="------" >Select one</option>
    <option value="Us.East N-L Sofcore">Us.East N-L Sofcore</option>
    <option value="Us.East N-L Hardcore">Us.East N-L Hardcore</option>
    <option value="Us.East L Softcore">Us.East L Softcore</option>      
    <option value="Us.East L Hardcore">Us.East L Hardcore</option>
    <option value="Us.West N-L Sofcore">Us.West N-L Sofcore</option>
    <option value="Us.West N-L Hardcore">Us.West N-L Hardcore</option>
    <option value="Us.West L Softcore">Us.West L Softcore</option>        
    <option value="Us.West L Hardcore">Us.West L Hardcore</option>
    <option value="Europe N-L Sofcore">Europe N-L Sofcore</option>
    <option value="Europe N-L Hardcore">Europe N-L Hardcore</option>
    <option value="Europe L Softcore">Europe L Softcore</option>             
    <option value="Europe L Hardcore">Europe L Hardcore</option>           
    <option value="Asia N-L Sofcore">Asia N-L Sofcore</option>
    <option value="Asia N-L Hardcore">Asia N-L Hardcore</option>
    <option value="Asia L Softcore">Asia L Softcore</option>           
    <option value="Asia L Hardcore">Asia L Hardcore</option>
</select>

</td>
</tr>
</table>

<input name="save" type="submit" value="Save Item">
</form>

Link to comment
Share on other sites

try and give the form an action to the php self

 

by the way you said that it is not working?

 

what happens when you click save ?

 

what error do you get?

add this bit. to your code

 

 

}

else{

echo 'Failed to add item';

}

?>

<form method="post">

 

 

let us know wot error u get

Link to comment
Share on other sites

A single quote is missing in your query after $itemn.

   $query = " INSERT INTO items (itemn, realm) ".
            " VALUES ('$itemn, '$realm')";

 

try using

 

   $query = " INSERT INTO items (itemn, realm) ".
            " VALUES ('$itemn', '$realm')";

Link to comment
Share on other sites

A single quote is missing in your query after $itemn.

   $query = " INSERT INTO items (itemn, realm) ".
            " VALUES ('$itemn, '$realm')";

 

try using

 

   $query = " INSERT INTO items (itemn, realm) ".
            " VALUES ('$itemn', '$realm')";

 

Lol, Thanks a lot man -.-

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.