tabel om en om kleuren uit db
Dit is de volledige code:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<table style="font-size: 70%;">
<?php
$sql = "SELECT `RecordID`, `Naam`, `Jaar`, `Discipline`, `Prestatie` FROM tblRecords WHERE Type = '" . $obj->Type . "' AND Geslacht = '" . $obj->Geslacht . "' AND OI='Outdoor';";
if ($list = mysql_query($sql, $link)) {
$flip = 0;
while($record = mysql_fetch_object($list)) {
$flip ^= 1;
if($_SESSION['level'] == 1) {
$edit = "onclick=\"self.location.href='a_edit_clubrecord.php?id=" . $record->RecordID . "'\"";
} else {
$edit = "";
}
if ($flip) {
$edit .= ' style="background: #fff"';
}
else {
$edit .= ' style="background: #eee"';
}
?>
<tr onmouseover="this.style.backgroundColor='#afe890'" onmouseout="this.style.backgroundColor='#fff'"<?php echo $edit; ?>>
<td style="width: 100px;"><?php echo htmlentities(stripslashes($record->Discipline)); ?></td>
<td style="width: 350px;"><?php echo htmlentities(stripslashes($record->Naam)); ?></td>
<td style="width: 50px;"><?php echo htmlentities(stripslashes(stripslashes($record->Prestatie))); ?></td>
<td style="width: 50px;"><?php echo htmlentities(stripslashes($record->Jaar)); ?></td>
</tr>
<?php
}
}
?>
</table>
<?php
$sql = "SELECT `RecordID`, `Naam`, `Jaar`, `Discipline`, `Prestatie` FROM tblRecords WHERE Type = '" . $obj->Type . "' AND Geslacht = '" . $obj->Geslacht . "' AND OI='Outdoor';";
if ($list = mysql_query($sql, $link)) {
$flip = 0;
while($record = mysql_fetch_object($list)) {
$flip ^= 1;
if($_SESSION['level'] == 1) {
$edit = "onclick=\"self.location.href='a_edit_clubrecord.php?id=" . $record->RecordID . "'\"";
} else {
$edit = "";
}
if ($flip) {
$edit .= ' style="background: #fff"';
}
else {
$edit .= ' style="background: #eee"';
}
?>
<tr onmouseover="this.style.backgroundColor='#afe890'" onmouseout="this.style.backgroundColor='#fff'"<?php echo $edit; ?>>
<td style="width: 100px;"><?php echo htmlentities(stripslashes($record->Discipline)); ?></td>
<td style="width: 350px;"><?php echo htmlentities(stripslashes($record->Naam)); ?></td>
<td style="width: 50px;"><?php echo htmlentities(stripslashes(stripslashes($record->Prestatie))); ?></td>
<td style="width: 50px;"><?php echo htmlentities(stripslashes($record->Jaar)); ?></td>
</tr>
<?php
}
}
?>
</table>
Je ziet dus dat ik maar 1 keer de opmaak van de tabel staan heb, en dat hij automatisch de rijen om en om een andere kleur geeft.
Gewijzigd op 01/01/1970 01:00:00 door Jan H
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
$sql = "SELECT `RecordID`, `Naam`, `Jaar`, `Discipline`, `Prestatie` FROM tblRecords WHERE Type = '" . $obj->Type . "' AND Geslacht = '" . $obj->Geslacht . "' AND OI='Outdoor';";
if ($list = mysql_query($sql, $link)) {
$flip = 0;
while($record = mysql_fetch_object($list)) {
$flip ^= 1;
if($_SESSION['level'] == 1) {
$edit = "onclick=\"self.location.href='a_edit_clubrecord.php?id=" . $record->RecordID . "'\"";
} else {
$edit = "";
}
if ($flip) {
$edit .= " onmouseover=\"this.style.backgroundColor='#afe890'\" onmouseout=\"this.style.backgroundColor='#fff'\" style=\"background: #fff\"";
}
else {
$edit .= " onmouseover=\"this.style.backgroundColor='#afe890'\" onmouseout=\"this.style.backgroundColor='#eee'\" style=\"background: #eee\"";
}
?>
<tr<?php echo $edit; ?>>
<td style="width: 100px;"><?php echo htmlentities(stripslashes($record->Discipline)); ?></td>
<td style="width: 350px;"><?php echo htmlentities(stripslashes($record->Naam)); ?></td>
<td style="width: 50px;"><?php echo htmlentities(stripslashes(stripslashes($record->Prestatie))); ?></td>
<td style="width: 50px;"><?php echo htmlentities(stripslashes($record->Jaar)); ?></td>
</tr>
<?php
}
}
?>
$sql = "SELECT `RecordID`, `Naam`, `Jaar`, `Discipline`, `Prestatie` FROM tblRecords WHERE Type = '" . $obj->Type . "' AND Geslacht = '" . $obj->Geslacht . "' AND OI='Outdoor';";
if ($list = mysql_query($sql, $link)) {
$flip = 0;
while($record = mysql_fetch_object($list)) {
$flip ^= 1;
if($_SESSION['level'] == 1) {
$edit = "onclick=\"self.location.href='a_edit_clubrecord.php?id=" . $record->RecordID . "'\"";
} else {
$edit = "";
}
if ($flip) {
$edit .= " onmouseover=\"this.style.backgroundColor='#afe890'\" onmouseout=\"this.style.backgroundColor='#fff'\" style=\"background: #fff\"";
}
else {
$edit .= " onmouseover=\"this.style.backgroundColor='#afe890'\" onmouseout=\"this.style.backgroundColor='#eee'\" style=\"background: #eee\"";
}
?>
<tr<?php echo $edit; ?>>
<td style="width: 100px;"><?php echo htmlentities(stripslashes($record->Discipline)); ?></td>
<td style="width: 350px;"><?php echo htmlentities(stripslashes($record->Naam)); ?></td>
<td style="width: 50px;"><?php echo htmlentities(stripslashes(stripslashes($record->Prestatie))); ?></td>
<td style="width: 50px;"><?php echo htmlentities(stripslashes($record->Jaar)); ?></td>
</tr>
<?php
}
}
?>
Edit: Code tags toegevoegd.
Gewijzigd op 01/01/1970 01:00:00 door - SanThe -
Perfect!