473,395 Members | 2,713 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,395 software developers and data experts.

Select-Abfrage nach dropdown-Vorgabe abändern!?

Hi,

i save junior football results in a mysql table
(FIELDS id jugend autor sptag ergebnis spdatum zeit )

With the following lines I generate a site whichs gives me ALL results

Code:
<table border="0" cellspacing="1" cellpadding="2" class="content"
width="100%">
<?
$sqlbefehl= "Select *
From $jugendtab b
Left Outer Join $tab_user u on u.id=b.autor
Order By b.jugend ASC Limit $eintrag,$zps";
$ergebnis = mysql_query($sqlbefehl, $serverid);
while ( $spiel = mysql_fetch_array ($ergebnis)) {
echo "<tr>";
//Jugendmannschaft
echo "<td align=\"center\" class=\"left\" bgcolor=\"$c_right\">";
echo $spiel['jugend'];
echo "</td>";
//Spieltag
echo "<td align=\"center\" class=\"right\" bgcolor=\"$c_right\">";
echo $spiel['sptag'];
echo "</td>";
//Datum ###########:
echo "<td align=\"center\" class=\"left\" bgcolor=\"$c_left\"><font
size=\"1\"><nobr>";
echo date("d.m.Y",$spiel[spdatum]+$time_offset);
echo "</nobr></td></tr>";
?>
</table>
Now I want make dropdown menu above which has all junior teams inside
(junior teams token comes from the mysql field "jugend" and is e.g. A,
B, etc.).

When a user selects e.g. "B" from this dropdown only the lines which
has "B" in the "jugend"-field should be displayed.

How can I do that?

Thanks

Regards,
Jagg
Jul 17 '05 #1
3 2275
jagg wrote:

How can I do that?


To let you know your title was German...

--
Google Blogoscoped
http://blog.outer-court.com
Jul 17 '05 #2
jagg wrote:
With the following lines I generate a site whichs gives me ALL results

Code:
<table border="0" cellspacing="1" cellpadding="2" class="content"
width="100%">
<?
$sqlbefehl= "Select *
From $jugendtab b
Left Outer Join $tab_user u on u.id=b.autor
Order By b.jugend ASC Limit $eintrag,$zps";
$ergebnis = mysql_query($sqlbefehl, $serverid);
while ( $spiel = mysql_fetch_array ($ergebnis)) {
echo "<tr>";
//Jugendmannschaft
echo "<td align=\"center\" class=\"left\" bgcolor=\"$c_right\">";
echo $spiel['jugend'];
echo "</td>";
//Spieltag
echo "<td align=\"center\" class=\"right\" bgcolor=\"$c_right\">";
echo $spiel['sptag'];
echo "</td>";
//Datum ###########:
echo "<td align=\"center\" class=\"left\" bgcolor=\"$c_left\"><font
size=\"1\"><nobr>";
echo date("d.m.Y",$spiel[spdatum]+$time_offset);
echo "</nobr></td></tr>";
?>
</table>

Now I want make dropdown menu above which has all junior teams inside
(junior teams token comes from the mysql field "jugend" and is e.g. A,
B, etc.).

When a user selects e.g. "B" from this dropdown only the lines which
has "B" in the "jugend"-field should be displayed.

How can I do that?


Add a form on the page:

<form>
<select name="opt">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<input type="submit" value="View">
</form>

Then in the code, change to something like this:

if(isset($_GET['opt'])){
$sqlbefehl= "Select *
From $jugendtab b
Left Outer Join $tab_user u on u.id=b.autor
Where b.jugend = '{$_GET['opt']}' Limit $eintrag,$zps";
}else{
$sqlbefehl= "Select *
From $jugendtab b
Left Outer Join $tab_user u on u.id=b.autor
Order By b.jugend ASC Limit $eintrag,$zps";
}

HTH

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #3
Justin Koivisto <sp**@koivi.com> wrote in message news:<xd******************@news7.onvoy.net>...
Add a form on the page:

<form>
<select name="opt">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<input type="submit" value="View">
</form>

Then in the code, change to something like this:

if(isset($_GET['opt'])){
$sqlbefehl= "Select *
From $jugendtab b
Left Outer Join $tab_user u on u.id=b.autor
Where b.jugend = '{$_GET['opt']}' Limit $eintrag,$zps";
}else{
$sqlbefehl= "Select *
From $jugendtab b
Left Outer Join $tab_user u on u.id=b.autor
Order By b.jugend ASC Limit $eintrag,$zps";
}

HTH


THANKS YOU VERY MUCH!!!!

It works!

Jagg
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Elroyskimms | last post by:
Using SQL 2000... tblCustomer: CustomerID int CompanyName varchar(20) HasRetailStores bit HasWholesaleStores bit HasOtherStores bit tblInvoiceMessages:
4
by: bobsawyer | last post by:
I've been building a series of SELECT lists that are populated dynamically using HTTPRequest. Things are going pretty well, and I've got the whole thing working flawlessly in Mozilla/Firebird....
3
by: dumbledad | last post by:
Hi All, I'm confused by how to replace a SELECT statement in a SQL statement with a specific value. The table I'm working on is a list of words (a column called "word") with an index int...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
1
by: serena.delossantos | last post by:
Trying to insert into a history table. Some columns will come from parameters sent to the store procedure. Other columns will be filled with a separate select statement. I've tried storing the...
9
chunk1978
by: chunk1978 | last post by:
hey everyone, i've been trying to solve this problem for 2 days straight, with no end in sight. i would greatly appreciate anyone's help. EXPLANATION: There are 3 Select Menus. The 1st and...
2
by: naima.mans | last post by:
Hello, i want to select 2 following brothers nodes wich are one under another (one closed to another)... i have done one xslt file... but it's not really good.. for example: the xml file:...
4
by: rn5a | last post by:
A Form has 2 select lists. The 1st one whose size is 5 (meaning 5 options are shown at any given time) allows multiple selection whereas the 2nd one allows only 1 option to be selected at a time. ...
2
by: artev | last post by:
if I insert a string null in a select, it change position; why? I insert value "" in 2nd 3th select; <style type="text/css"> td {border:2px solid pink;}; </style>
6
by: Apaxe | last post by:
In the database i have a table with this information: key_id =1 key_desc =43+34+22+12 I want sum the values in key_desc. Something like: SELECT key_desc FROM table But the result of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.