Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Multiple Drop Down Menu PHP, need help

views
     
TSPeach88
post Apr 9 2010, 08:58 AM, updated 14y ago

New Member
*
Junior Member
29 posts

Joined: Jan 2010
From: backstabbing world


Hi, does anyone know how to create a multiple down down menu using php? for example, in job location, user gets to choose 3 different job location from 3 different drop down menu, and send these information to the database. i've tried to search thru tutorials but dun really understand the coding @.@.

anyway in the database, should i put all 3 information in a single field?
hiroshimaru
post Apr 9 2010, 09:19 AM

New Member
*
Junior Member
20 posts

Joined: Dec 2007
From: クランタウン



u mean something like this?

CODE

<?php
echo "Select Processor Type 1 : ";
echo "<select name=processor>";
echo "<option value=\"AMD\">AMD</a></option>";
echo "<option value=\"INTEL\">INTEL</a></option>";
echo "<option value=\"OTHER\">OTHER</a></option>";
echo "</select><br>";
echo "Select Processor Type 2 : ";
echo "<select name=processor2>";
echo "<option value=\"AMD2\">AM2D</a></option>";
echo "<option value=\"INTEL2\">INTEL2</a></option>";
echo "<option value=\"OTHER2\">OTHER2</a></option>";
echo "</select><br>";
echo "Select Processor Type 3 : ";
echo "<select name=processor3>";
echo "<option value=\"AMD\">AMD3</a></option>";
echo "<option value=\"INTEL\">INTEL3</a></option>";
echo "<option value=\"OTHER\">OTHER3</a></option>";
echo "</select>";
?>

TSPeach88
post Apr 9 2010, 11:39 AM

New Member
*
Junior Member
29 posts

Joined: Jan 2010
From: backstabbing world


QUOTE(hiroshimaru @ Apr 9 2010, 09:19 AM)
u mean something like this?

CODE

<?php
echo "Select Processor Type 1 : ";
echo "<select name=processor>";
echo "<option value=\"AMD\">AMD</a></option>";
echo "<option value=\"INTEL\">INTEL</a></option>";
echo "<option value=\"OTHER\">OTHER</a></option>";
echo "</select><br>";
echo "Select Processor Type 2 : ";
echo "<select name=processor2>";
echo "<option value=\"AMD2\">AM2D</a></option>";
echo "<option value=\"INTEL2\">INTEL2</a></option>";
echo "<option value=\"OTHER2\">OTHER2</a></option>";
echo "</select><br>";
echo "Select Processor Type 3 : ";
echo "<select name=processor3>";
echo "<option value=\"AMD\">AMD3</a></option>";
echo "<option value=\"INTEL\">INTEL3</a></option>";
echo "<option value=\"OTHER\">OTHER3</a></option>";
echo "</select>";
?>

*
yes, this is the multiple drop down menu, but this is the html form. need the PHP function to make it work >.<''
d8kd
post Apr 9 2010, 12:18 PM

I'm watching over you
*****
Senior Member
879 posts

Joined: Nov 2004
QUOTE(Peach88 @ Apr 9 2010, 11:39 AM)
yes, this is the multiple drop down menu, but this is the html form. need the PHP function to make it work >.<''
*
wat do u mean by php function? by calling the menu's info & value from database?
hiroshimaru
post Apr 9 2010, 12:28 PM

New Member
*
Junior Member
20 posts

Joined: Dec 2007
From: クランタウン



try look for this..
I thing u can get some idea hehe blush.gif

dropdown.php
CODE

<?php

echo "<form id=\"FormName\" action=\"insert.php\" method=\"post\" name=\"FormName\">\n";
echo "Select Processor Type 1 : ";
echo "<select name=processor>";
echo "<option value=\"AMD\">AMD</a></option>";
echo "<option value=\"INTEL\">INTEL</a></option>";
echo "<option value=\"OTHER\">OTHER</a></option>";
echo "</select><br>";
echo "Select Processor Type 2 : ";
echo "<select name=processor2>";
echo "<option value=\"AMD2\">AM2D</a></option>";
echo "<option value=\"INTEL2\">INTEL2</a></option>";
echo "<option value=\"OTHER2\">OTHER2</a></option>";
echo "</select><br>";
echo "Select Processor Type 3 : ";
echo "<select name=processor3>";
echo "<option value=\"AMD\">AMD3</a></option>";
echo "<option value=\"INTEL\">INTEL3</a></option>";
echo "<option value=\"OTHER\">OTHER3</a></option>";
echo "</select>";
echo "<input type=\"submit\" name=\"submitButtonName\" value=\"Insert Data\">\n";
?>


insert.php

CODE

<?php
//database connection
include('./inc/connect.php');

// get data from form
$processor1 = $_POST['processor'];
$processor2 = $_POST['processor2'];
$processor3 = $_POST['processor3'];

// Mysql Insert Query
$query = "INSERT INTO processor (Processor1, processor2, processor3)
VALUES ('$processor1', '$processor2', '$processor3')";
$results = mysql_query($query);

// check if data sucessful insert or not..
if ($results)
{
echo "Details added.";
}
else
{
echo "Mysql Error<br>";
die(mysql_error());
echo "<a href=\"index.php\">Back to List</a><br>";
}
mysql_close();

?>



or u want dynamic drop down.. it use javascript to work..

if u want auto populate select item u must have database to work then integrated the form with database query...

it's something like this..
CODE


$res=mysql_query("SELECT * FROM cpu order by productname,description") or die(mysql_error());

echo "<select name=processor>";
while($row=mysql_fetch_assoc($res)) {

echo "<option value=\" $row[productname] $row[description]\">$row[productname] $row[description]</a></option>";
}
echo "</select>";


This post has been edited by hiroshimaru: Apr 9 2010, 12:33 PM
musleh
post Apr 15 2010, 11:57 AM

Getting Started
**
Junior Member
67 posts

Joined: Feb 2010


QUOTE(Peach88 @ Apr 9 2010, 11:39 AM)
yes, this is the multiple drop down menu, but this is the html form. need the PHP function to make it work >.<''
*
What do you mean by PHP function to make it work? PHP also using HTML code to make a form. Did you know it?
alien3d
post Apr 16 2010, 07:34 PM

Look at all my stars!!
*******
Senior Member
3,740 posts

Joined: Mar 2009
Php is just a server side.check up jquery chained query instead.
JusticeDeserves
post Apr 18 2010, 11:09 AM

Regular
******
Senior Member
1,914 posts

Joined: Aug 2009


CODE
<?php
$sql = 'SELECT * FROM pages';
$result = mysql_query($sql);
?>

<ul>
 <li><a href="index.php">Home</a></li>
<?php
while($row = mysql_fetch_array($result) {
  echo '<li>'.$row['page_name'].'</li>';
}
?>
</ul>


Something like that? Just style it up so it acts like a dropdown. smile.gif
anti-informatic
post Apr 18 2010, 11:57 AM

Enthusiast
*****
Senior Member
902 posts

Joined: Dec 2006
u dont need php to make a drop down list, that only on the html side
i guess what u looking for the the php script that store the selected drop down value and save to the database, in which hiroshimaru and justiceDeserve has show u an example
mista_amin
post May 18 2010, 04:22 PM

Getting Started
**
Junior Member
67 posts

Joined: Sep 2007


im having the same kind of problem.
im new to php.anyone can give me direction on how to create dynamic dropdown list.first dropdown list will determine what to show in second dropdown list.both data comes from database and then being saved back to database in another table.
thanks in advance
goldfries
post May 18 2010, 04:39 PM

40K Club
Group Icon
Forum Admin
44,409 posts

Joined: Jan 2003




the logic is very simple.

retrieve from DB, output to HTML.

the dropdown part is done with HTML / CSS. nothing to do with PHP.

PHP is just retrieving, you just need to work out the logic.
.:Jin:.
post May 18 2010, 05:03 PM

New Member
*
Junior Member
5 posts

Joined: Jan 2003
From: Penang


it suprise me how u guys understand what he want.. i totaly dont understand what he intended to do LOL...

and the php function is another ???? for me in his question...

mista_amin
post May 18 2010, 05:39 PM

Getting Started
**
Junior Member
67 posts

Joined: Sep 2007


sory for my noob question sweat.gif
its hard for me to explain what i wanna do.
anyway tq n sory for troubling u guys notworthy.gif notworthy.gif

 

Change to:
| Lo-Fi Version
0.0153sec    0.37    5 queries    GZIP Disabled
Time is now: 29th March 2024 - 05:18 AM