Turn your Mobile Apps into m-commerce apps – Learn More!

You're Browsing As A Guest! Register Now...
Become a PHP Expert!

Join 415,725 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,713 people online right now.Registration is fast and FREE... Join Now!



php multiple dependent drop down menus Rate Topic: -----

#1 dima09  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-June 09


Dream Kudos: 0

Share |

php multiple dependent drop down menus

Posted 01 June 2009 - 07:35 PM

Hi,
I am trying to have 2 drop down lists created and have the 2nd drop down be based on the selection of the 1st.

Questions:
1) What would be more efficient, a mysql database or a CSV flat file to pull data from (assuming about 100-200 rows of data)?
2) Do i have to use javascript for validation, to make sure the proper choices are selected (any drawbacks to using javascript?)

Thanks in advance!

This post has been edited by dima09: 01 June 2009 - 07:35 PM

Was This Post Helpful? 0
  • +
  • -


#2 DingleNutZ  Icon User is offline

  • D.I.C Head
  • PipPip

Reputation: 0
  • View blog
  • Posts: 117
  • Joined: 02-May 09


Dream Kudos: 0

Re: php multiple dependent drop down menus

Posted 01 June 2009 - 08:26 PM

it depend really on your preferences and if you gave out the right options why would you need to check it?
if you do really want to validate it though, javascript would only work on browsers that have it enable or ones that have it installed, this is usually most peoples browsers though
Was This Post Helpful? 0
  • +
  • -

#3 ShaneK  Icon User is online

  • require_once("brain.php"); //Fatal error :/
  • Icon

Reputation: 165
  • View blog
  • Posts: 1,039
  • Joined: 10-May 09


Dream Kudos: 150

Expert In: PHP, MySQL

Re: php multiple dependent drop down menus

Posted 01 June 2009 - 08:32 PM

...I wouldn't validate through Javascript, because (since it's client sided) it can easily be modified by the user.

Yours,
Shane~
Was This Post Helpful? 0
  • +
  • -

#4 noorahmad  Icon User is offline

  • Author
  • Icon

Reputation: 161
  • View blog
  • Posts: 2,200
  • Joined: 12-March 09


Dream Kudos: 1650

Re: php multiple dependent drop down menus

Posted 01 June 2009 - 09:14 PM

if you are using a Dynamic Drop Down Menu then you can use CSS+Javascript+PHP/ASP, i am using a vertically sub menu in website using CSS, Javascript and PHP+MySQL and it works very good for me.
Was This Post Helpful? 0
  • +
  • -

#5 dima09  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-June 09


Dream Kudos: 0

Re: php multiple dependent drop down menus

Posted 02 June 2009 - 08:59 AM

so how do i go about doing this dependent drop down list and is it better to work with mysql or a CSV file is just as good?
Was This Post Helpful? 0
  • +
  • -

#6 dima09  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-June 09


Dream Kudos: 0

Re: php multiple dependent drop down menus

Posted 02 June 2009 - 02:04 PM

Hi Guys,
So far i have created a CSV flat file and i got a php script to put the comma separated values into an array.. here's the setup:

manufacturer,model,price

how can i create two drop down lists that will return the manufacturer and respective models?
for example, i want people to select a manufacturer and then have the 2nd drop down list adjust per 1st manufacturer choice

Thanks!!
Was This Post Helpful? 0
  • +
  • -

#7 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • Icon

Reputation: 553
  • View blog
  • Posts: 3,338
  • Joined: 08-August 08


Dream Kudos: 100

Expert In: PHP

Re: php multiple dependent drop down menus

Posted 02 June 2009 - 02:19 PM

View Postdima09, on 2 Jun, 2009 - 06:04 PM, said:

Hi Guys,
So far i have created a CSV flat file and i got a php script to put the comma separated values into an array.. here's the setup:

manufacturer,model,price

how can i create two drop down lists that will return the manufacturer and respective models?

Are there many options? If there aren't too many manufacturers, models, and prices, I'd create java script arrays and insert the values from php into the javascript. Then it's just a matter of using javascript to change the values based on the selections.

Either that, our you're looking at ajax.

This post has been edited by CTphpnwb: 02 June 2009 - 02:20 PM

Was This Post Helpful? 0
  • +
  • -

#8 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • Icon

Reputation: 553
  • View blog
  • Posts: 3,338
  • Joined: 08-August 08


Dream Kudos: 100

Expert In: PHP

Re: php multiple dependent drop down menus

Posted 02 June 2009 - 02:37 PM

:D

You're probably wondering what the heck I was talking about!

Here's short example. I took this javascript and duplicated it using an array in php:

http://www.w3schools...ame=tryjs_array
<?php
echo "<html><body>\n";
echo '<script type="text/javascript">';
echo '
var mycars = new Array();
';
$phparray = array("Saab","Volvo","BMW");

for($i=0;$i<count($phparray); $i++) {
	echo 'mycars['.$i.'] = "'.$phparray[$i].'";
';
}
echo 'for (i=0;i<mycars.length;i++)
{
document.write(mycars[i] + "<br />");
}
</script>
';
echo "</body></html>";
?>


Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users