[SOLVED] Creating multiple dynamic list boxes from mysql database

This is a discussion on "[SOLVED] Creating multiple dynamic list boxes from mysql database" within the PHP Forum section. This forum, and the thread "[SOLVED] Creating multiple dynamic list boxes from mysql database are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 19th, 2007, 11:51
New Member
Join Date: Sep 2007
Location: KENYA
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Creating multiple dynamic list boxes from mysql database

Am new here hi all yo.

Can someone please explain how to do this Creating Dependant dynamic list boxes from mysql database.

Am using dreamweaver and my method is causing the whole page to refresh I dont want that.

Thanks please help
eeeeh am in Kenya

  #2 (permalink)  
Old Sep 19th, 2007, 12:35
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Creating multiple dynamic list boxes from mysql database

Are you using PHP or .NET?
  #3 (permalink)  
Old Sep 19th, 2007, 12:41
New Member
Join Date: Sep 2007
Location: KENYA
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Creating multiple dynamic list boxes from mysql database

Am using php and mysql database I really NEED URGENT HELP
  #4 (permalink)  
Old Sep 19th, 2007, 12:48
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Creating multiple dynamic list boxes from mysql database

Well ... you won't get much help in the Intro forum

Moved to the PHP forum.

Now ... you're going to have to explain what it is you want in more detail. Do you have a page setup already? Show us the code you have, etc...
  #5 (permalink)  
Old Oct 18th, 2007, 09:43
New Member
Join Date: Sep 2007
Location: KENYA
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Creating multiple dynamic list boxes from mysql database

Hi got the dynamic list box to work and its getting my makes and models ok but now I cant send the values to the search page which is to give me the makes images from my db.

Help now

How do I get to send the make value selected to my waiting record set in the search page.

Davibugi

PHP: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
</head>
<?php 
 
if (!isset($passed_value)){ $passed_value=2;}// make
if (!isset($passed_value2)){ $passed_value2=3;}// make
 
?>
<body onLoad="redirect(<?php echo $passed_value.','.$passed_value2?>,2)">
<table width="790" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="790" height="600" valign="top"><form id="form1" name="form1" method="POST" action="buy a motor2.php">
<table width="91%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="5">&nbsp;</td>
</tr>
<tr>
<td colspan="4" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>&nbsp;</td>
</tr>
</table></td>
<td width="173" rowspan="4" valign="top" background="http://www.webforumz.com/images/guidebar.jpg"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="9%">&nbsp;</td>
<td width="84%"><p class="style1">&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p></td>
<td width="7%">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td width="12" rowspan="2" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
<td width="290" valign="top" bgcolor="#FFFFFF"><span class="style8"><a href="contact us.php"></a> |<a href="#"></a></span></td>
<td width="303" rowspan="2" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
<td width="12" colspan="-1" rowspan="3" bgcolor="#FFFFFF">&nbsp;</td>
</tr>
<tr>
<td valign="bottom" bgcolor="#FFFFFF"><a href="#">
<?php 
 
 
include('con1.php');
 
$sql="select * from carmake";
 
$sql2="select * from carmodel WHERE carid=".$passed_value;
$result=mysql_query($sql,$id_link) or die (mysql_error());
$result2=mysql_query($sql2,$id_link) or die (mysql_error());
?>
</a></td>
</tr>
<tr>
<td height="473" colspan="3" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0">
<tr>
<td width="21%" height="187" rowspan="13" valign="top"><p class="style1">&nbsp;</p></td>
<td width="2%" rowspan="13" valign="top">&nbsp;
<p>&nbsp;</p></td>
<td width="24%">&nbsp;</td>
<td colspan="4">&nbsp;</td>
<td width="4%" rowspan="13">&nbsp;</td>
</tr>
<tr>
<td colspan="5"><span class="style42">Search for your make and model </span></td>
</tr>
 
 
<tr>
<td valign="top" class="style1">Email Address<span class="style62">*:</span></td>
<td colspan="4" valign="top" class="style1"><input name="email" type="text" class="style9" id="email" /></td>
</tr>
<tr>
<td valign="top" class="style1"><span class="style9">Telephone<span class="style62">* <span class="style63">(+254)</span></span>:</span></td>
<td colspan="4" valign="top" class="style1"><input name="telephone" type="text" class="style9" id="telephone" /></td>
</tr>
<tr>
<td valign="top" class="style1">Make<span class="style62">*</span>:</td>
<td colspan="4" valign="top" class="style1"><select name="make" size="1" class="style1" onchange="redirect(this.options.selectedIndex,<?php echo $passed_value.','.$passed_value2?>)">
<option selected="selected">-select-</option>
<?php
 
// as the idnumber is stored in the table with all results, here we compare to set SELECTED
// this is a standard formula for retrieving stored info about a box selection
while ($newarray=mysql_fetch_array($result)) {
echo 
'<option value="'.$newarray['idnumber'].'" ';
if (
$newarray['idnumber']==$passed_value) {echo "SELECTED";};
echo 
'>'.$newarray['makes'].'</option>'.'\n';
?>
</select></td>
</tr>
<tr>
<td height="20" valign="top"><span class="style1">
<label>Model<span class="style62">*</span>:</label>
</span></td>
<td colspan="4" valign="top" class="style1"><select name="model" size="1" class="style1">
<?php 
// here we do the same for the second box
 
while ($newarray=mysql_fetch_array($result2)) { 
echo 
'<option value="'.$newarray['idnumber'].'" ';
if (
$newarray['idnumber']==$passed_value2) {echo "SELECTED";};
echo 
'>'.$newarray['models'].'</option>';
$x=$x+1;} ?>
</select></td>
</tr>
<tr>
<td valign="top" class="style1"><label for="label">Minimum Year:</label></td>
<td width="12%" valign="top" class="style1"><select name="minYear" class="style1" id="minYear">
<option value="(All)" selected="selected">(All)</option>
<option>2003</option>
<option>2002</option>
<option>2001</option>
<option>2000</option>
<option>1999</option>
<option>1998</option>
<option>1997</option>
<option>1996</option>
<option>1995</option>
<option>1994</option>
<option>1993</option>
<option>1992</option>
<option>1991</option>
<option>1990</option>
<option>1989</option>
<option>1988</option>
</select></td>
<td width="19%" valign="top" class="style1"><label for="label" class="maxyear">Max. Year:</label></td>
<td colspan="2" valign="top" class="style1"><select name="maxYear" class="style1" id="maxYear">
<option value="(All)" selected="selected">(All)</option>
<option>2003</option>
<option>2002</option>
<option>2001</option>
<option>2000</option>
<option>1999</option>
<option>1998</option>
<option>1997</option>
<option>1996</option>
<option>1995</option>
<option>1994</option>
<option>1993</option>
<option>1992</option>
<option>1991</option>
<option>1990</option>
<option>1989</option>
<option>1988</option>
</select></td>
</tr>
<tr>
<td valign="top"><span class="style1">
<label for="label">Fuel Type:</label>
<label></label>
</span></td>
<td valign="top" class="style1"><select name="fuelType" class="style1" id="fuelType">
<option value="(All)" selected="selected">(All)</option>
<option value="Petrol">Petrol</option>
<option value="Diesel">Diesel</option>
</select></td>
<td valign="top" class="style1"><label for="label" class="category">Vehicle Category:</label></td>
<td colspan="2" valign="top" class="style1"><select name="vehicleCategory" class="style1" id="vehicleCategory">
<option>Sports Car</option>
<option>Passenger</option>
<option>SUV &amp; 4X4</option>
<option>Commercial </option>
<option>Truck</option>
</select></td>
</tr>
 
 
<tr>
<td valign="top" class="style1"><label for="label">Price Range (In Kshs) :</label>
<label></label>
<label for="label"></label> </td>
<td colspan="4" valign="top" class="style1"><label for="label">
<input name="price" class="style1" id="price" onkeypress="return isNumb(this, event);" size="10" maxlength="10" />
<span class="unit">&nbsp;kshs To</span>
<input name="txtPriceMax2" class="style1" id="txtPriceMax2" onkeypress="return isNumb(this, event);" size="10" maxlength="10" />
<span class="unit">&nbsp;kshs</span></label></td>
</tr>
 
 
<tr>
<td valign="top" class="style1"><label for="label" class="style1">How did you hear about autosokoni.com<span class="style62">*</span>? </label></td>
<td colspan="4" valign="top" class="style1"><p>
<select name="learnMattauto" class="style1" id="reference">
<option value="0" selected="selected">Please Choose</option>
<option value="9">Google</option>
<option value="8">Yahoo</option>
<option value="12">Other Search Engine</option>
<option value="1">Friend</option>
<option value="5">Magazine or Periodical</option>
<option value="2">Email</option>
<option value="4">Newspaper</option>
<option value="6">Flyers</option>
<option value="7">Billboards</option>
<option value="11">Other sites</option>
</select>
</p></td>
</tr>
<tr>
<td height="22" valign="top" class="style1">&nbsp;</td>
<td colspan="2" valign="top" class="style1"><input name="Submit" type="submit" class="style1" onclick="MM_validateForm('email','','RisEmail','telephone','','NisNum','price','','NisNum','txtPriceMax2','','NisNum');return document.MM_returnValue" value="Submit" /></td>
<td colspan="2" valign="top" class="style1">&nbsp;</td>
</tr>
<tr>
<td height="22" colspan="5" valign="top" bgcolor="#999999" class="style1">&nbsp;</td>
</tr>
<tr>
<td colspan="5" valign="top" class="style42"><table width="99%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="33%">&nbsp;</td>
<td width="31%">&nbsp;</td>
<td width="36%">&nbsp;</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="1%">&nbsp;</td>
<td colspan="3" valign="top"><blockquote>&nbsp;</blockquote></td>
</tr>
</table></td>
<td valign="top" bgcolor="#FFFFFF">&nbsp;</td>
<td width="173" valign="top" bgcolor="#000000">&nbsp;</td>
</tr>
<tr>
<td colspan="5" bgcolor="#000000"><blockquote>&nbsp;</blockquote></td>
</tr>
</table>
<p>
<script>
 
var groups=document.form1.make.options.length
var group=new Array(groups)
for (i=0; i<groups; i++){
group[i]=new Array
 
}
<?php 
//Here comes the data from the two linked tables in a format suited for JScripting
// into the script mentioned here above
 
$sql="select * from carmake";
 
$result=mysql_query($sql,$id_link) or die (mysql_error());
$x=0;$y=0;$m=0;$z=1;
 
while (
$newarray=mysql_fetch_array($result)) { 
echo 
"group[0][$m]=new Option(\"".$newarray['makes'].'","'.$newarray['idnumber'].'")'."\n";
$sql2="select * from carmodel WHERE carid=".$newarray['idnumber']." order by idnumber asc";
$result2=mysql_query($sql2,$id_link) or die (mysql_error());
 
 
while (
$newarray2=mysql_fetch_array($result2)) {
echo 
"group[$z][$y]=new Option(\"".$newarray2['models'].'","'.$newarray2['idnumber'].'")'."\n";
$y=$y+1;
 
}
$z=$z+1;
$y=0;
$m=$m+1;
}
?>
 
 
var temp=document.form1.model
function redirect(x,d,f){
 
for (m=temp.options.length-1;m>0;m--)
 
temp.options[m]=null
 
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[eval(x)][i].text,group[eval(x)][i].value)
}
temp.options[d].selected=true
 
}
 
//-->
</script>
</p>
</form>
<body>
</body>
</html>

Last edited by Rakuli; Oct 18th, 2007 at 09:50. Reason: Please use [php][/php] BBC tags when posting code
  #6 (permalink)  
Old Oct 18th, 2007, 09:55
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Re: Creating multiple dynamic list boxes from mysql database

You need to change the form method to GET so that it posts the variables to the browser nad in you search page you get the variables from the browser to do your search
  #7 (permalink)  
Old Oct 18th, 2007, 13:15
New Member
Join Date: Sep 2007
Location: KENYA
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Creating multiple dynamic list boxes from mysql database

sorry the problem is not yet solved I cant use get cause I post the values to my inbox in the results page.

Please help I need to get the value of make to be posted

Thanks
  #8 (permalink)  
Old Oct 19th, 2007, 14:35
New Member
Join Date: Sep 2007
Location: KENYA
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Creating multiple dynamic list boxes from mysql database

here is the code that am talking about.

I want to post akt_groep but in my case its sending idnumber kindly have a look at it and give me a way foward it can be found on this link

http://www.weberdev.com/download.php...e=4211.zip.ber

Thanks
  #9 (permalink)  
Old Oct 19th, 2007, 14:54
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Re: Creating multiple dynamic list boxes from mysql database

Is it not online anywhere so people can look? You'll likely to get more help if people see what you are trying to do
  #10 (permalink)  
Old Nov 16th, 2007, 04:46
New Member
Join Date: Sep 2007
Location: KENYA
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Creating multiple dynamic list boxes from mysql database

Hi people please help me out with this code cant find any person who has done it before.

I want my calculations to be done without posting to another page. On change on the entered amount the results are displayed please help

Asante (Swahili for thanks)

Here is my code

HTML: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style10 {color: #004200;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 9px;
    font-style: normal;
    line-height: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: capitalize;
}
-->
</style>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="335" height="83" border="0">
    <!--DWLayoutTable-->
    <tr>
      <td height="20" colspan="2" valign="top" class="style10">Amount Banked </td>
      <td colspan="2" valign="top"><input name="textfield310" type="text" class="style10" />
      what the client keys in </td>
    </tr>
    <tr>
      <td height="20" colspan="2" valign="top" class="style10">Charges</td>
      <td colspan="2" valign="top"><input name="textfield311" type="text" class="style10" disabled="disabled"/>
      rates are to come from the database </td>
    </tr>
    <tr>
      <td height="20" colspan="2" valign="top" class="style10">Balance available to send </td>
      <td colspan="2" valign="top"><input name="textfield312" type="text" class="style10" disabled="disabled" /></td>
    </tr>
  </table>
</form>
</body>
</html>

Last edited by c010depunkk; Nov 16th, 2007 at 06:17. Reason: Please use [HTML] tags when displaying HTML
  #11 (permalink)  
Old Nov 16th, 2007, 04:49
New Member
Join Date: Sep 2007
Location: KENYA
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Creating multiple dynamic list boxes from mysql database

eeeeeeeeeeh and thanks the previous script i was working on on dynamic list menues is now working. you can view it at www.autosokoni.com/buy%20a%20motor%20vehicle.php thanks for your help
  #12 (permalink)  
Old Nov 20th, 2007, 06:12
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: [SOLVED] Creating multiple dynamic list boxes from mysql database

THREAD CLOSED (cleaning up)
Closed Thread

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Help with HTML form to database (mysql/php)! skuliaxe PHP Forum 7 Jan 20th, 2008 00:41
[SOLVED] Please help with creating a Mailing list form. Oak Starting Out 3 Dec 26th, 2007 18:54
[SOLVED] Linking php code to a form &amp; mysql database longstand PHP Forum 21 Oct 9th, 2007 16:40
php/mysql database fields into html list/menu csun PHP Forum 4 Jul 27th, 2007 16:04
Creating multiple dynamic list boxes from mysql database phoenix211984 Databases 1 Sep 27th, 2006 16:19


All times are GMT. The time now is 02:05.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43