Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-30-2011, 09:09 PM   PM User | #1
nick.elliott10
New Coder

 
Join Date: Oct 2011
Location: Cambridgeshire, UK
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
nick.elliott10 is an unknown quantity at this point
Dynamic Drop Down Menu

I have managed to write the code for a dynamic dropdown menu, as can be seen below.

PHP Code:
<?php
include("../../includes/db/connect.php");

$query "SELECT * FROM `termdates`";
$result mysql_query($query) or die(mysql_error());

$dropdown "<select name='term'>";
while(
$row mysql_fetch_assoc($result))
{
$dropdown .= "\r\n<option value='{$row['termID']}'>{$row['termText']}</option>";
}
$dropdown .= "\r\n</select>";
echo 
$dropdown;

mysql_close();
?>
However, depending on the value selected from the drop down menu, I need it to show the term dates for the year selected. Does any one have any suggestions?

Thank you for any help in advance.
nick.elliott10 is offline   Reply With Quote
Old 11-30-2011, 09:47 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
I don't understand question.
You're currently selecting everything without any conditions.
Somewhere before the query, you need to specify a year and then
create a condition in the query to only pull-out those rows that match the year.

I guess I don't see what "year selected" means?
mlseim is offline   Reply With Quote
Old 11-30-2011, 10:02 PM   PM User | #3
nick.elliott10
New Coder

 
Join Date: Oct 2011
Location: Cambridgeshire, UK
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
nick.elliott10 is an unknown quantity at this point
I want it so that the user and select the academic year from the drop down menu, which is database driven and then it will query the database again and return the term dates for that academic year.

Basically, like this (http://www.cromwellcc.org.uk/about/t...s/Default.aspx) but in PHP/mySQL.

Thanks.
nick.elliott10 is offline   Reply With Quote
Old 11-30-2011, 10:11 PM   PM User | #4
myfayt
Senior Coder

 
Join Date: Apr 2010
Posts: 1,156
Thanks: 46
Thanked 95 Times in 94 Posts
myfayt can only hope to improve
Use Ajax for this, or Javascript.
__________________
Been a sign maker for 5 years. My business:
American Made Signs
myfayt is offline   Reply With Quote
Old 12-01-2011, 12:09 AM   PM User | #5
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
If it's OK to refresh the screen, you won't need AJAX, but if
you want it to be "fluid" changing, with a page refresh, you'll
need to use AJAX (PHP and Javascripting).
mlseim is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:04 PM.


Advertisement
Log in to turn off these ads.