ERLEDIGT
JA
JA
ANTWORTEN
4
4
ZUGRIFFE
4470
4470
EMPFEHLEN
-
09.04.05 16:56 #1
Hallo ich habe eine Frage wie kann ich das Format der Datums ausgaben ändenr damit es nicht mehr 2005-4-9 ist sondern 9.4.2005?
hier ist mein Code:
PHP-Code:<?
include 'config.php';
if($res_id = @mysql_pconnect( "$mysql_host", "$mysql_user", "$mysql_pw"))
{
echo "";
}
else
{
die('Fehler! Datenbank gibt es nicht.');
}
if(@mysql_select_db("$mysql_db"))
{
echo "";
}
else
{
die('Fehler! Datenbank gibt es nicht.');
}
// DIES IST ZUM AUSGEBEN DER DATEN DER TABELLE
$sql = "SELECT * FROM news ORDER BY `id` DESC";
if (!$res_id = mysql_query($sql))
die ('Fehler! SQL-Befehl ist Falsch.');
while ($news = mysql_fetch_array($res_id))
{
echo "<font face=\"Verdana\"><table>";
echo "<tr><td>";
echo "<b><font size=\"-1\">";
echo $news['Titel'];
echo "</font></b>";
echo " ";
echo "<font size=\"-2\">";
echo $news['Datum'];
echo "</font></td></tr>";
echo "<tr><td><font size=\"-1\">";
echo $news['Inhalt'];
echo "</font><br><font size=\"-2\">verfasst von <b>";
echo $news['autor'];
echo "</b></font></td></tr>";
echo "</table></font>";
echo "<br>";
}
?>
-
PHP-Code:
$datum = explode("-", $news['Datum']);
$news['Datum'] = $datum['2'].".".$datum['1'].".".$datum['0'];
-
Probier mal Folgendes:
PHP-Code:<?php
include 'config.php';
if( !$res_id = @mysql_pconnect($mysql_host, $mysql_user, $mysql_pw) ) {
die('Fehler! Datenbank gibt es nicht.');
}
if( !@mysql_select_db($mysql_db) ) {
die('Fehler! Datenbank gibt es nicht.');
}
// DIES IST ZUM AUSGEBEN DER DATEN DER TABELLE
$query = "
SELECT
`Titel`,
DATE_FORMAT(`Datum`, '%d.%m.%Y') AS `datum_formatiert`,
`Inhalt`,
`author`
FROM
`news`
ORDER BY
`id` DESC
";
if( !$res_id = mysql_query($query) ) die('Fehler! SQL-Befehl ist Falsch.');
while( $row = mysql_fetch_array($res_id) ) {
echo '<h2>'.$row['Titel'].'</h2>';
echo '<div class="news-item"><span class="date">'.$row['datum_formatiert'].'</span>';
echo '<div>'.$row['Inhalt'].'</div>';
echo '<span class="author">verfasst von <strong>'.$row['autor'].'</strong></span></div>';
}
?>
-
09.04.05 17:39 #4
Wenn ich den Code so änder erscheint auf der seite Fehler! SQL-Befehl ist Falsch. also irgendwas stimmt dort nicht!
-
09.04.05 17:42 #5
Ich habs selber hinbekommen der neue Code heisst nu
Danke für deinene AnsatzPHP-Code:<?
include 'config.php';
if($res_id = @mysql_pconnect( "$mysql_host", "$mysql_user", "$mysql_pw"))
{
echo "";
}
else
{
die('Fehler! Datenbank gibt es nicht.');
}
if(@mysql_select_db("$mysql_db"))
{
echo "";
}
else
{
die('Fehler! Datenbank gibt es nicht.');
}
// DIES IST ZUM AUSGEBEN DER DATEN DER TABELLE
$sql = "SELECT
DATE_FORMAT(`Datum`, '%d.%m.%Y') AS `datum_formatiert`,
`Inhalt`,
`autor`,
`Titel`
FROM news ORDER BY `id` DESC";
if (!$res_id = mysql_query($sql))
die ('Fehler! SQL-Befehl ist Falsch.');
while ($news = mysql_fetch_array($res_id))
{
echo "<font face=\"Verdana\"><table>";
echo "<tr><td>";
echo "<b><font size=\"-1\">";
echo $news['Titel'];
echo "</font></b>";
echo " ";
echo "<font size=\"-2\">";
echo $news['datum_formatiert'];
echo "</font></td></tr>";
echo "<tr><td><font size=\"-1\">";
echo $news['Inhalt'];
echo "</font><br><font size=\"-2\">verfasst von <b>";
echo $news['autor'];
echo "</b></font></td></tr>";
echo "</table></font>";
echo "<br>";
}
?>
Ähnliche Themen
-
Datumsformat
Von javaxy im Forum JavaAntworten: 6Letzter Beitrag: 26.06.07, 15:43 -
Datumsformat
Von iLu_is_a_loser im Forum Relationale DatenbanksystemeAntworten: 2Letzter Beitrag: 09.04.05, 16:41 -
Datumsformat
Von xony im Forum PHPAntworten: 1Letzter Beitrag: 22.02.05, 15:07 -
Datumsformat
Von Nici im Forum Relationale DatenbanksystemeAntworten: 4Letzter Beitrag: 14.12.04, 15:59 -
datumsformat
Von lanadra im Forum Relationale DatenbanksystemeAntworten: 3Letzter Beitrag: 30.03.04, 17:47





Zitieren
Login






[PHP][Snippet] Array zu XML konvertieren