Jump to content


This topic is now archived and is closed to further replies.


PHP, MySql and HTML select menus

Recommended Posts


I'm relatively new to HTML and PHP, but have been programming PLSQL for some years, and I am aware that this question might be simple, but if you don't know the answer...

I am trying to produce a site that has two <select type> lists on one of the pages that are populated from the database. The first list works fine but to get the second one to work I need to send the result value from the first select to the PHP script that controls the second. I don't know if this can be done easily as I realise that PHP is server based and HTML / Java is local.

Example of first select follows:

<select name="first" id="first" onChange="price_up(flag_form.first.value)">
<?php do
{ ?>
<option value="<?php echo $row_rs_first_list['Category_ID']?>"><?php echo $row_rs_first_list['Category_Type']?></option>
<?php }
while ($row_rs_first_list = mysql_fetch_assoc($rs_first_list));
$rows = mysql_num_rows($rs_first_list);
if($rows > 0)
mysql_data_seek($rs_first_list, 0);
$row_rs_first_list = mysql_fetch_assoc($rs_first_list);

The function "price_up" just displays the value of the select.

Anybody got any advice?


Share this post

Link to post
Share on other sites
Basically there are 3 ways

1 ) php

on selecting from first, submit the page and refresh the second menu then redisplay page

2 ) javascript

You need to create js arrays of options for each of the options in the first menu. Use js to refresh the second menu from the corresponding array. (baaSelect in my sig works like this)

3 ) xmlhttp request

see [a href=\"http://members.aol.com/barryaandrew/xmlhttp/article.html\" target=\"_blank\"]here[/a] for examples

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.