Tourplan

Tags:    php

Hej hej

Jeg mangler lige lidt hjælp til hvordan jeg vender bunden i vejret på vores tourplan.
Dvs. som det er nu ryger de sidst overståede jobs ned i bunden af listen - vi vil gerne have dem til at være for oven...forstået?!
Ellers sig til;-)


Hjemmesiden hvor I kan se den som den er nu hedder: www.metzband.dk.



Her er koden:


<body bgcolor="#FFFFFF">

<?php
// read in the connection settings
require("./administration/tourplan/showlister_settings.inc");

// connect to the RDBMS
$db = mysql_connect("$site","$user","$pass") or die_now("<h2>Could not connect to database server</h2><p>Check passwords and sockets</p>");

// select the database
mysql_select_db("$database",$db) or die_now("<h2>Could not select database $database</h2><p>Check database name</p>");

// select all the shows in the database
$result = mysql_query("select show_id, dagnavn, month, day, year, location, details, venue from $database_table where afholdt='' order by year, month, day ASC",$db) or die_now("<h2>Could not select shows</h2>");

// output the current shows
echo("<h3 align='center'><font color='#000000'>Tourplan</font></h3>");
echo("<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='80%' align='center'>\\n");
echo("\\t<tr bgcolor='#BD2929'>\\n\\t\\t<td><b><font color='#FFFFFF'>Dato</font></td>\\n\\t\\t<td></td>\\n\\t\\t<td></td>\\n\\t\\t<td><b><font color='#FFFFFF'>Spillested</font></b></td>\\n\\t\\t<td><b><font color='#FFFFFF'>By</font></b></td>\\n\\t\\t<td><b><font color='#FFFFFF'>Tidspunkt</font></b></td>\\n\\t\\t</tr>\\n");
while($row = mysql_fetch_array($result)) {
$the_id = $row["show_id"];
$the_dagnavn = $row["dagnavn"];
$the_month = $row["month"];
$the_day = $row["day"];
$the_year = $row["year"];
$the_location = $row["location"];
$the_details = $row["details"];
$the_venue = $row["venue"];

//Laver nummer om til måned
switch($the_month) {
case "1": $the_month="Januar"; break;
case "2": $the_month="Februar"; break;
case "3": $the_month="Marts"; break;
case "4": $the_month="April"; break;
case "5": $the_month="Maj"; break;
case "6": $the_month="Juni"; break;
case "7": $the_month="Juli"; break;
case "8": $the_month="August"; break;
case "9": $the_month="September"; break;
case "10": $the_month="Oktober"; break;
case "11": $the_month="November"; break;
case "12": $the_month="December"; break;
}

// shows
echo("\\t<tr>\\n\\t\\t<td style='border-bottom:1px solid #FFFFFF'><font color='#000000'>" . "$the_dagnavn" . "</font></td>\\n");
echo("\\t\\t<td align=right style='border-bottom:1px solid #FFFFFF'><font color='#000000'>" . "$the_day" . "</font></td>\\n");
echo("\\t\\t<td style='border-bottom:1px solid #FFFFFF'><font color='#000000'>" . ". " . "$the_month" . "</font></td>\\n");
echo("\\t\\t<td style='border-bottom:1px solid #FFFFFF'><font color='#000000'>" . "$the_venue" . "</font></td>\\n");
echo("\\t\\t<td style='border-bottom:1px solid #FFFFFF'><font color='#000000'>" . "$the_location" . "</font></td>\\n");
echo("\\t\\t<td align=right style='border-bottom:1px solid #FFFFFF'><font color='#000000'>" . "$the_details" . "</font></td>\\n");

}
echo("\\t</tr></table>\\n</div>\\n");
?>


<?php
// read in the connection settings
require("./administration/tourplan/showlister_settings.inc");

// connect to the RDBMS
$db = mysql_connect("$site","$user","$pass") or die_now("<h2>Could not connect to database server</h2><p>Check passwords and sockets</p>");

// select the database
mysql_select_db("$database",$db) or die_now("<h2>Could not select database $database</h2><p>Check database name</p>");

// select all the shows in the database
$result = mysql_query("select show_id, dagnavn, month, day, year, location, details, venue from $database_table where afholdt='checked' order by year, month, day ASC",$db) or die_now("<h2>Could not select shows</h2>");

// output the current shows
echo("<h3 align='center'><font color='#000000'>Afholdte Koncerter</font></h3>");
echo("<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='80%' align='center'>\\n");
echo("\\t<tr bgcolor='#BD2929'>\\n\\t\\t<td><b><font color='#FFFFFF'>Dato</font></td>\\n\\t\\t<td></td>\\n\\t\\t<td></td>\\n\\t\\t<td><b><font color='#FFFFFF'>Spillested</font></b></td>\\n\\t\\t<td><b><font color='#FFFFFF'>By</font></b></td>\\n\\t\\t<td><b><font color='#FFFFFF'>Tidspunkt</font></b></td>\\n\\t\\t</tr>\\n");
while($row = mysql_fetch_array($result)) {
$the_id = $row["show_id"];
$the_dagnavn = $row["dagnavn"];
$the_month = $row["month"];
$the_day = $row["day"];
$the_year = $row["year"];
$the_location = $row["location"];
$the_details = $row["details"];
$the_venue = $row["venue"];

//Laver nummer om til måned
switch($the_month) {
case "1": $the_month="Januar"; break;
case "2": $the_month="Februar"; break;
case "3": $the_month="Marts"; break;
case "4": $the_month="April"; break;
case "5": $the_month="Maj"; break;
case "6": $the_month="Juni"; break;
case "7": $the_month="Juli"; break;
case "8": $the_month="August"; break;
case "9": $the_month="September"; break;
case "10": $the_month="Oktober"; break;
case "11": $the_month="November"; break;
case "12": $the_month="December"; break;
}

// shows
echo("\\t<tr>\\n\\t\\t<td style='border-bottom:1px solid #FFFFFF'><font color='#000000'>" . "$the_dagnavn" . "</font></td>\\n");
echo("\\t\\t<td align=right style='border-bottom:1px solid #FFFFFF'><font color='#000000'>" . "$the_day" . "</font></td>\\n");
echo("\\t\\t<td style='border-bottom:1px solid #FFFFFF'><font color='#000000'>" . ". " . "$the_month" . "</font></td>\\n");
echo("\\t\\t<td style='border-bottom:1px solid #FFFFFF'><font color='#000000'>" . "$the_venue" . "</font></td>\\n");
echo("\\t\\t<td style='border-bottom:1px solid #FFFFFF'><font color='#000000'>" . "$the_location" . "</font></td>\\n");
echo("\\t\\t<td align=right style='border-bottom:1px solid #FFFFFF'><font color='#000000'>" . "$the_details" . "</font></td>\\n");

}
echo("\\t</tr></table>\\n</div>\\n");
?>
<br>





2 svar postet i denne tråd vises herunder
1 indlæg har modtaget i alt 3 karma
Sorter efter stemmer Sorter efter dato
Hold da op, det var noget af en kode...

Når du trækker ud fra databasen, skal du bare skrive f.eks....

$result = mysql_query("select bla bla bla from $database_table where bla bla bla ORDER BY date DESC) or die_now("bla bla bla");

Altså, du har en dato liggende i databasen, så skal du bare få den til at sortere resultaterne DESC (som i Descending), istedet for ASC (som i Ascending)....

Altså tilføje ORDER BY date DESC (hvor date udskriftes med den kolonnes navn i database, som indeholder din dato)

Udover det, så er det sateme meget kode for en tourliste. Vores bands ser sådan ud:

<?php

include("connect.php");

$sql = "select * from tourListe ORDER BY date DESC";
$result = mysql_query($sql) or die(mysql_error());

while ($row = mysql_fetch_array($result))
{
print('d. <b>'.date_format($row["date"]).'</b>    ');
print('<b>'.$row["spilleSted"].'</b>    ');
print($row["comment"].'  ');
}
?>


... og gør præcis det samme



Ja, det må da siges at være en del lettere - og langt mere overskueligt at kigge på!



t