PHP Applications
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Applications

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 21st, 2008, 12:23 PM
hostsb hostsb is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 1 hostsb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 46 sec
Reputation Power: 0
PHP Dynamic Drop Down Boxes Help Please

I am Looking to do a dropdown Boxes array in php mysql
Year Make Model Description and Link
to do something like this

if year = 2000 show ford - chevy ........
if ford is selected show car - truck
if truck is selected show f-150 - f-250-
if f-250 selected show Link to site

I have seen this in dropdown boxes and the page does not change
here is what I have been playing with but it shows up blank.
It was not my code but code I had sugested to me
Pleae look and let me know what i am doing wrong

Index.php

<?
include("config.php");
$conn = mysql_connect($host, $user, $password);
mysql_select_db($dbname);

?>
<html>
<head>
<title>User Page</title>
</head>
<body>
<?
$vvar = array();
$vvar[0] = "";
for($i = 1;$i <= $maxSub;$i++) {
$vname = "v" . $i;
if (isset($_GET[$vname])) {
$vvar[$i] = $_GET[$vname];
} else {
break;
}
}

?>

<script type="text/javascript">
<?
$jsv = array();
$jsv[0] = "?";
for($i = 1;$i <= $maxSub;$i++) {
$jsv[$i] = $jsv[$i-1] . $vvar[$i-1] . "&v" . $i . "=";

?>
function select<?="v" . $i?>(v1) {
window.location = "<?=$jsv[$i]?>" + v1;
}
<?
}

?>
</script>
<form action="index.php" method="GET">
<table border="0">
<?
$parent = 1;
$str1 = "";
for($i = 1;$i <= $maxSub;$i++) {
$next = 0;
if ($parent != 0) {
$q1 = "select child_id from relation where parent_id='$parent' order by child_id";
$r1 = mysql_query($q1) or die(mysql_error());
if (isset($vvar[$i])) {
$sel = $vvar[$i];
$next = $sel;
} else {
$sel = 0;
}
$str1 .= "<option value=\"0\">Select Option</option>";
while ($arr1 = mysql_fetch_assoc($r1)) {
$id1 = $arr1['child_id'];
$q2 = "select name from node where id = '$id1'";
$r2 = mysql_query($q2) or die(mysql_error());
$arr2 = mysql_fetch_assoc($r2);
$n2 = $arr2['name'];
if ($id1 == $sel) {
$str1 .= "<option value=\"$id1\" selected=\"selected\">$n2</option>\n";
} else {
$str1 .= "<option value=\"$id1\">$n2</option>\n";
}
}
}

?>
<tr>
<td>
<?
if (strcmp($str1,"" ) == 0) {
?>
<select name="choice">
<option value="0">Select Option</option>
<?
} else {
?>
<select name="choice" onChange="select<?="v" . $i?>(this.options[this.selectedIndex].value)">
<?=$str1?>
</select>
<?
}
?>
</td>
</tr>
<?
$parent = $next;
$str1 = "";
}

?>
</table>
</form>
</body>
</html>
<?
if ($conn)
mysql_close($conn);

?>


Config.php

<?

$dbhost = "localhost";
$user = "lesspal_fred";
$password = "password";
$dbname = "lesspal_fred";

?>

mysql dump file


SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `lesspal_fred`
--

-- --------------------------------------------------------

--
-- Table structure for table `node`
--

CREATE TABLE IF NOT EXISTS `node` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `node`
--

INSERT INTO `node` (`id`, `name`) VALUES
(1, 'root');

-- --------------------------------------------------------

--
-- Table structure for table `relation`
--

CREATE TABLE IF NOT EXISTS `relation` (
`parent_id` int(10) unsigned NOT NULL default '0',
`child_id` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`parent_id`,`child_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `relation`
--



Please Help

[PHPNET="dynamic dropdown"]

Last edited by hostsb : October 21st, 2008 at 12:41 PM. Reason: added dump file

Reply With Quote
  #2  
Old September 29th, 2009, 01:03 PM
IROS IROS is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 5 IROS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 8 m 36 sec
Reputation Power: 0
Hi.
This is simple code for controlling list box items with Javascript.

<html>
<head>
<script language="javascript">
function go()
{
document.location.href=document.f1.s1.value;
}
</script>
</head>
<body>
<form method="post" name="f1">
<select id="s1" onchange="go()">
<option value="(URL address1)">yoursite1</option>
<option value="(URL address2)">yoursite2</option>
<option value="(URL address3)">yoursite3</option>
</select>
</form>
</body>
</html>

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Applications > PHP Dynamic Drop Down Boxes Help Please


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek