Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

> Multiple Drop Down Menu PHP, need help

views
     
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>";
?>

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

 

Change to:
| Lo-Fi Version
0.0214sec    0.14    6 queries    GZIP Disabled
Time is now: 26th February 2021 - 03:10 AM