473,748 Members | 6,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Static Drop down menu variable for mysql

5 New Member
Greetings, I have been attempting to make a drop down menu of countries. From this menu I wish to create a variable in order to INPUT into mysql database. I have no trouble making the drop down menu, but I am unable to store a variable for it.

Here is a rough copy of what I am making:

<html>
<head>
<title>Add New MySQL User</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?
if(isset($_POST['add']))
{
include 'c:\sokkit\conf ig.php';
include 'c:\sokkit\open db.php';

$username = $_POST['username'];
$password = $_POST['password'];

$query = "INSERT INTO account (username, password, location) VALUES ('$username', '$password', '$country')";
mysql_query($qu ery) or die('Error, insert query failed');

$query = "FLUSH PRIVILEGES";
mysql_query($qu ery) or die('Error, insert query failed');

include 'c:\sokkit\clos edb.php';
echo "New MySQL user added";
}
else
{
?>

<form name="myform" action="http://www.mydomain.co m/myformhandler.c gi" method="POST">
<div align="left">
<select name="mydropdow n">
<option value="Milk">Fr esh Milk</option>
<option value="Cheese"> Old Cheese</option>
<option value="Bread">H ot Bread</option>
</select>
</div>
</form>
<form method="post">
<table width="400" border="0" cellspacing="1" cellpadding="2" >
<tr>
<td width="100">Use rname</td>
<td><input name="username" type="text" id="username"> </td>
</tr>
<tr>
<td width="100">Pas sword</td>
<td><input name="password" type="text" id="password"> </td>
</tr>
<tr>
<td width="100">&nb sp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="100">&nb sp;</td>
<td><input name="add" type="submit" id="add" value="Add New User"></td>
</tr>
</table>
</form>
<?
}
?>
</body>
</html>

As you can see my mysql Insert command here:
$query = "INSERT INTO account (username, password, location) VALUES ('$username', '$password', '$country')";

I set it using the variable $country. But i have no way to store the variable from here:

<div align="left">
<select name="mydropdow n">
<option value="Milk">Fr esh Milk</option>
<option value="Cheese"> Old Cheese</option>
<option value="Bread">H ot Bread</option>
</select>
</div>

If someone could assist me in creating a stored variable from this drop down menu in order to INSERT into mysql database I would greatly appreciate it.

This is the return error when php script is run.
Notice: Undefined variable: country in C:\sokkit\site\ Accounts\dummy. php on line 17
New MySQL user added
Apr 3 '07 #1
2 5254
code green
1,726 Recognized Expert Top Contributor
$country = $_POST['mydropdown'];
Apr 3 '07 #2
Boujii
5 New Member
Thanks alot 'code green'. That worked just great.
Apr 8 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2963
by: KK | last post by:
Drop-down menus are the hottest thing since Wonder Bread but . . . 1. Alot of people put them in the they-look-nice-but-you-cant-code-them-right-so-they-always-look-messed-up category (a la "frames"). Do you think this is true> 2. Some people think they take up too much KB. 3. Some people are worried that people who have javascript turned off wont be able to see them. What percent of web users have javascrips turned off? I thought it was...
3
3052
by: scaredemz | last post by:
hi, so i'm creating a dynamic drop-down menu. the menu and the text show up fine in IE but only the drop-down shows in Firefox without the menu text. Below is the fxn code. help pls. function DropDownHelper(menuArray, top, left, height) { var currItem = new String(); var item; var idStr;
8
7461
by: barbarowa | last post by:
I've coded a script to populate a drop down menu from a database but I can't seem to get the PHP script to pass the selected item. The database only has two fields, ID and ITEM. I want the user to be able to see all the choices and pick one. This choice would then be used to update another database. The drop down menu populates correctly. When I test for the variable being passed, nothing is showing up. Here is the code: <?php
19
258997
by: mart2006 | last post by:
I've created a dynamic drop down menu that populates itself with data from a MySQL table. What I would like to do is create a non dynamic drop down menu that alters what is shown in the dynamic menu. For example, the first menu has three cities London, Paris, New York. If I choose London it populates the second menu with people from London. Here is the code I have for my dynamic menu <td valign=top><strong>Name:</strong></td> <td>...
1
2858
by: phpnewb | last post by:
Hi, I know i'm doing it wrong, but I'm using a while loop right now to create several instances of a drop down menu. It gives me undesirable results. Can you tell me the right way to do it. Below are a bit of information on what i did if you want t read it. When I choose select an option in the drop down menu and hit submit, I increase a counter, and a 2nd loop generates a second drop down menu with the same options. This is exactly what...
0
7359
by: tusaar | last post by:
Hi all I am in big need for a drop down menu created with php, mysql and ajax. Exactly, I need three drop down menu (Category, Subcategory and Item). The data of each drop down will come from Mysql. Anybody can help me please.. I will be very much thankfull. Please help me and give me a proper solution for that ASAP. Thanks Tushar
2
3066
by: ponyeyes | last post by:
Hi There, I am a bit of a newbie to PHP programming and I would like to know how I can place a selected drop down option into a PHP variable and then produce an sql query which incorporates this variable. I have created a dynamic drop down menu that populates itself with data from a MySQL table. I now want it to populate a second drop-down menu with relevant options from my database, based upon a query using a variable. For example........
10
57041
by: mart2006 | last post by:
Hi, I'm fairly new to PHP and I've created a dynamic drop down menu that populates itself with data from a MySQL table. What I would like to do is create a non dynamic drop down menu that alters what is shown in the dynamic menu. For example, the first menu has three cities London, Paris, New York. If I choose London it populates the second menu with people from London. Here is the code I have for my dynamic menu <td...
11
3663
SHOverine
by: SHOverine | last post by:
I have an issue with a drop down menu that I am hoping you all can help me with. The issue is when I press "Submit", my code prints back values from a form I developed (eventually I will write them to a database). In this form, I have a dynamically built drop down (php/ mysql query). No matter which value I select, it always prints the LAST row in the table (array) as the selected value. My code follows: 1) I connect to database 2) I am...
0
8987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9534
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8239
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.