Topics in extern site (Technics)
Auge, ich habe es so übernommen, wie du mir gesagt hast. Die Daten von der DB habe ich natürlich korrekt eingebaut.
Hier der Quellcode, der aktuell eingebaut ist: http://chat.fun2000.info/forum/test.php ist das Ergebnis von diesem Quellcode!
<?php $link = mysql_connect('localhost', 'XXX', 'XXX'); if (!$link) { $error[] = 'Verbindung nicht möglich: ' . mysql_error(); } else { // benutze Datenbank foo $db_selected = mysql_select_db('XXX', $link); if (!$db_selected) { $error[] = 'Kann foo nicht benutzen: ' . mysql_error(); } else { // the databese query $Query = "SELECT id, name, subject, UNIX_TIMESTAMP(time) AS time FROM ".$db_settings['forum_table']." ORDER BY time DESC LIMIT 0, 3"; // Kontrollausgabe des Queries echo '<pre>'.print_r($Query, true).'</pre>'; /** * Attention: You'll get the time as it's saved in the database * without respect for timezones settings! * * alternative ways for formatting time string: * DATE_FORMAT(time, 'MySQL-timeformat') AS time * instead UNIX_TIMESTAMP(time) AS time * * description: * with DATE_FORMAT you get a formatted date string out of the database * MySQL-timeformat: see http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format * * with UNIX_TIMESTAMP you have to generate the string with PHP later * because you'll get only a unix timestamp (seconds since 01.01.1970 00:00 UTC/GMT) */ // database request $rawResult = mysql_query($Query); // give result of query into an array $result = array(); while ($row = mysql_fetch_assoc($rawResult)) { $result[] = $row; } // generate output $output = '<div id="new-postings">'."\n"; $output .= ' <h2>Newest Postings</h2>'."\n"; if (count($result) > 0) { $output .= ' <ul>'."\n"; foreach ($result as $row) { // only needed if you use UNIX_TIMESTAMP in query, // formatting rules: see http://de3.php.net/manual/en/function.strftime.php $time = strftime("%Y%m%d",$row['time']); $output .= ' <li><a href="http://chat.fun2000.info/forum/index.php?id='.intval($row['id']).'">'.htmlspecialchars($row['subject']).'</a> - '.htmlspecialchars($row['name']).', '.htmlspecialchars($row['time']).'</li>'."\n"; } $output .= ' </ul>'."\n"; } else { $output .= '<p>There are no postings.</p>'."\n"; } $output .= '</div>'."\n"; // put output into HTML somewhere else echo $output; } } ?>