|
Тема |
Сортиране на таблица по всяка колонка |
|
Автор |
Гeлe Byтeв (Нелегален) |
|
Публикувано | 27.01.08 22:07 |
|
|
Здравейте, моля за малко помощ:
Искам, след като ми излезе таблицата с резултата от търсенето, да сложа линкове върху заглавията на всяка от трите колонки Кategorie, Jahr и Titel така, че да могат да се сортират резултатите.
Ето кода:
<HTML><HEAD>
<TITLE>Page1</TITLE>
</HEAD><BODY>
<table width="820"><tr>
<td <border-width: 2" width="140">
<p align="center"><b>Kategorie</b></td>
<td <border-width: 2" width="54">
<p align="center"><b>Jahr</b></td>
<td <border-width: 2" width="779">
<p align="center"><b>Titel</b></td>
</table>
<?php
$where = '';
if ( $_POST['v01'] ) { $where = "'v01'"; }
if ( $_POST['v02'] ) {
if ( $where ) {
$where .= " or `Bereich`='v02'";
} else {
$where = "'v02'";
}
}
if ( $_POST['v03'] ) {
if ( $where ) {
$where .= " or `Bereich`='v03'";
} else {
$where = "'v03'";
}
}
if ( $_POST['v04'] ) {
if ( $where ) {
$where .= " or `Bereich`='v04'";
} else {
$where = "'v04'";
}
}
if ( $_POST['v05'] ) {
if ( $where ) {
$where .= " or `Bereich`='v05'";
} else {
$where = "'v05'";
}
}
if ( $_POST['v06'] ) {
if ( $where ) {
$where .= " or `Bereich`='v06'";
} else {
$where = "'v06'";
}
}
if ( $_POST['v07'] ) {
if ( $where ) {
$where .= " or `Bereich`='v07'";
} else {
$where = "'v07'";
}
}
if ( $_POST['v08'] ) {
if ( $where ) {
$where .= " or `Bereich`='v08'";
} else {
$where = "'v08'";
}
}
if ( $_POST['v09'] ) {
if ( $where ) {
$where .= " or `Bereich`='v09'";
} else {
$where = "'v09'";
}
}
if ( $_POST['v10'] ) {
if ( $where ) {
$where .= " or `Bereich`='v10'";
} else {
$where = "'v10'";
}
}
if ( $_POST['v11'] ) {
if ( $where ) {
$where .= " or `Bereich`='v11'";
} else {
$where = "'v11'";
}
}
if ( $_POST['v12'] ) {
if ( $where ) {
$where .= " or `Bereich`='v12'";
} else {
$where = "'v12'";
}
}
if ( $_POST['v13'] ) {
if ( $where ) {
$where .= " or `Bereich`='v13'";
} else {
$where = "'v13'";
}
}
if ( $_POST['v14'] ) {
if ( $where ) {
$where .= " or `Bereich`='v14'";
} else {
$where = "'v14'";
}
}
if ( $_POST['v15'] ) {
if ( $where ) {
$where .= " or `Bereich`='v15'";
} else {
$where = "'v15'";
}
}
if ( $_POST['v16'] ) {
if ( $where ) {
$where .= " or `Bereich`='v16'";
} else {
$where = "'v16'";
}
}
if ( $_POST['v17'] ) {
if ( $where ) {
$where .= " or `Bereich`='v17'";
} else {
$where = "'v17'";
}
}
mysql_connect("localhost", "username", "password");
mysql_select_db("database1");
$result = mysql_query("SELECT * FROM `Table1` WHERE `Bereich`=$where ORDER BY 'Kategorie';");
$anzahl=mysql_numrows($result);
echo '<table width="820">';
while ( $row = mysql_fetch_array( $result ) ) {
echo "<tr>
<td style=\"border-style: solid; border-width: 2\" width=\"140\">
$row[Kategorie]
</td>
<td style=\"border-style: solid; border-width: 2\" width=\"37\">
$row[Jahr]
</td>
<td style=\"border-style: solid; border-width: 2\" width=\"796\">
$row[Titel]
</td>
</tr>
";
}
echo '</table>';
echo "$anzahl Datensätze gefunden";
mysql_close();
?>
</BODY></HTML>
Може ли някой да помогне, как да го направя това сортиране?
Мерси предварително
Шамар да е, аванта да е.Редактирано от Гeлe Byтeв на 27.01.08 22:08.
|
| |
|
|
|