Showing MySQL result problem

wxdqz

New Member
Hi!
I got these three tables in a db with courses. Each one have a different headline/subheadline (subtitel) and "maintext".

CREATE TABLE amu (
amuId int(8) DEFAULT '0' NOT NULL auto_increment,
headline varchar(100) NOT NULL,
subhead varchar(100),
tekst text NOT NULL,
PRIMARY KEY (amuId)
);

CREATE TABLE amu_data (
amuNr varchar(8) NOT NULL,
placeId char(2) NOT NULL,
amuId int(8) DEFAULT '0' NOT NULL,
start date DEFAULT '0000-00-00' NOT NULL,
end date DEFAULT '0000-00-00' NOT NULL,
frist date DEFAULT '0000-00-00' NOT NULL,
PRIMARY KEY (amuNr)
);

CREATE TABLE udd_steder (
placeId char(2) NOT NULL,
place varchar(20) NOT NULL,
PRIMARY KEY (stedId)
);


One course (in the amu table) may take place in different places (identified by udd_steder table) at different dates and with different numbers (identified by amu_data).
I can show one course with headline, subheadline, text and a HTML-table the numbers, dates and so on:
HEADLINE course1-something
Subtitel course1-something
text course1-something
_________________________________________________
Number |Begin | End | Frist | Place |
_________________________________________________
13-456 |2001-02-02|2001-03-02|2001-01-02| City1 |
_________________________________________________
16-555 |2001-02-09|2001-03-09|2001-01-15| City2 |
_________________________________________________
19-576 |2001-02-15|2001-03-13|2001-02-20| City1 |


$query = mysql_query("SELECT amu.headline, amu.subhead, amu.tekst FROM amu WHERE amu.amuId='$id'");

WHILE($r = mysql_fetch_array($query)){
$overskr = $r["headline"];
$underskr = $r["subhead"];
$brodteks = $r["tekst"];

ECHO "<TR><TD>$overskr</TD></TR><TR><TD>$underskr</TD></TR><TR><TD>$brodteks </TD></TR>";
}
ECHO "</TABLE><BR>";
...
$query = mysql_query("SELECT amu_data.amuNr, amu_data.start, amu_data.end, amu_data.frist, udd_steder.place FROM amu_data, udd_steder WHERE amu_data.amuId = '$id' AND udd_steder.placeId = amu_data.placeId ");

WHILE($r = mysql_fetch_array($query)){
$nr = $r["amuNr"];
$startdate = $r["start"];
$enddate = $r["end"];
$frist = $r["frist"];
$place = $r["place"];

ECHO "<TR><TD ALIGN=\"center\">$nr</TD><TD ALIGN=\"center\">$startdate - $enddate</TD><TD ALIGN=\"center\">$place</TD><TD ALIGN=\"center\">$frist</TD></TR>";
}
ECHO "</TABLE>";

But I can not figure out how to show all the courses on one page as a kind of calender. Something like this:
HEADLINE course1-something
_________________________________________________
Number |Begin | End | Frist | Place |
_________________________________________________
13-456 |2001-02-02|2001-03-02|2001-01-02| City1 |
_________________________________________________
16-555 |2001-02-09|2001-03-09|2001-01-15| City2 |
_________________________________________________
19-576 |2001-02-15|2001-03-13|2001-02-20| City1 |


HEADLINE course2-something
_________________________________________________
Number |Begin | End | Frist | Place |
_________________________________________________
14-456 |2001-04-14|2001-05-02|2001-03-02| City1 |
_________________________________________________
15-888 |2001-06-09|2001-07-09|2001-05-15| City3 |

Maybe something wrong with the db design or?
Thank you!
Ole
 
Back
Top