Jump to content

PHP, MySql and HTML select menus


freddixon

Recommended Posts

Hi,

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);
}
?>
</select>

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


Anybody got any advice?

Thanks

Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.