473,405 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how to join 2 select box's

52
I have 2 select box's

The first box selects season's from the database and works giving an url like index.php?season=1970-71

The second box gets filled with dates (months) from the season row's and works giving an url like index.php?month=1970-08-15

I need to be able to get an url like index.php?season=1970-71&month=08 is this possible?


[PHP]$query = ("SELECT DISTINCT (season) FROM premiership");

echo" ".$season."";
echo" <form action=\"index.php\" method=\"GET\" name=\"form1\">
<label>Season
<select name=\"season\">";

$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$selectseason = $row['season'];
echo" <option>".$selectseason."";
echo" </option>";
}
echo" </select>
</label><input type=\"submit\" value=\"Submit\">
</form>";

if (isset($_GET['season']))
{
$lastseason= $_GET['season'];
}else{
$lastseason=$selectseason;
}
echo" ".$lastseason."";
//-----------------------------------------
$query = ("SELECT DISTINCT (gamedate) FROM premiership WHERE season = '".$lastseason."' ");
echo" <form action=\"index.php\" method=\"GET\" name=\"form2\">
<label>month
<select name=\"month\">";

$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$selectmonth = $row['gamedate'];
echo" <option>".$selectmonth."";
echo" </option>";
}
echo" </select>
</label><input type=\"submit\" value=\"Submit\">
</form>";[/PHP]
Jul 30 '07 #1
5 1264
hinksta
52
Just a note - On the finished page I would want to get rid of the second box (month) and use links like below

[HTML]echo"<table border=\"0\" align=\"center\" cellspacing=\"1\" cellpadding=\"5\">
<tr>
<td><a href=\"index.php?season=".$lastseason."&amp;month= 08\">Aug</a></td>
<td><a href=\"index.php?season=".$lastseason."&amp;month= 09\">Sep</a></td>
<td><a href=\"index.php?season=".$lastseason."&amp;month= 10\">Oct</a></td>
<td><a href=\"index.php?season=".$lastseason."&amp;month= 11\">Nov</a></td>
<td><a href=\"index.php?season=".$lastseason."&amp;month= 12\">Dec</a></td>
<td><a href=\"index.php?season=".$lastseason."&amp;month= 01\">Jan</a></td>
<td><a href=\"index.php?season=".$lastseason."&amp;month= 02\">Feb</a></td>
<td><a href=\"index.php?season=".$lastseason."&amp;month= 03\">Mar</a></td>
<td><a href=\"index.php?season=".$lastseason."&amp;month= 04\">Apr</a></td>
<td><a href=\"index.php?season=".$lastseason."&amp;month= 05\">May</a></td>
</tr>
</table>"; [/HTML]
Jul 30 '07 #2
kovik
1,044 Expert 1GB
I'm failing to see any problem. If you put all selections into the same form, you'd get the result you were after.
Jul 30 '07 #3
hinksta
52
Thanks it worked, I thought of that last night and then forgot it.

now i've just go to figure out how to get it the month from 2007-08-15 to just 08
Jul 30 '07 #4
kovik
1,044 Expert 1GB
Thanks it worked, I thought of that last night and then forgot it.

now i've just go to figure out how to get it the month from 2007-08-15 to just 08
Take a look at PHP's date() and strtotime() functions.
Jul 30 '07 #5
hinksta
52
Great, that's project 1, part 1 of 3 done.

Thank you for your help
Jul 30 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: red | last post by:
This is a simple join but I am having trouble with it. I feel like such an idiot. I start with this select statement, which works fine: $query = "SELECT a.auction, a.winner, b.id FROM...
17
by: guitarromantic | last post by:
Hey everyone. I'm re-writing a php Content Management System (based loosely on phpNuke but specific to my site). My first major change was attempting to normalise the Review section database...
0
by: B. Fongo | last post by:
I learned MySQL last year without putting it into action; that is why I face trouble in formulating my queries. Were it a test, then you would have passed it, because your queries did help me...
7
by: alexcn | last post by:
I have the following query: SELECT dbo.tSymExch.exCode, dbo.tSymGrp.sgCode, dbo.tSymMain.smCode FROM dbo.tSymExch FULL OUTER JOIN dbo.tSymGrp ON dbo.tSymExch.exID =...
0
by: Joe | last post by:
I'm trying to get the following query optimized: SELECT box.box_id, box.phone_number, buildings.name as building_name, buildings.id as building_id, accounts.name as account_name from...
14
by: Jim Andersen | last post by:
I have a problem with this standard employee-supervisor scenario For pictures: http://www.databasedev.co.uk/self-join_query.html I want to show all employees "belonging" to a specific...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
0
by: MarsLandingParty | last post by:
Hello All, I have managed to create a partitioned view ona large table - the view is updateable, and looking at the execution plan, only the relevant table is queried. The partition is by...
4
by: Stubbie | last post by:
Hello! I have a query that joins two tables in my Access 97 database: SELECT Table1.A, Table1.B, Table1.C, Table2.E FROM Table2 INNER JOIN Table1 on Table2.D = Table1.C; The query works...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.