Topics in extern site (Technics)

by Christian @, Saturday, December 11, 2010, 21:42 (4856 days ago) @ Auge

Hallo Auge,

danke für dein Posting.
Habe folgenden Code eingebaut:

<?php

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
$error[] = 'Verbindung nicht möglich: ' . mysql_error();
} else {
// benutze Datenbank foo
$db_selected = mysql_select_db('foo', $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";

/**
* 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 youll 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" valign="top">'."\n";
$output .= '<p align="left"><b>Letzten Beiträge:</b></p>'."\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("PHP-timeformat",$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>in Bearbeitung</p>'."\n";
}
$output .= '</div>'."\n";

// put output into HTML somewhere else
echo $output;
}
}
?>


Aber es funktioniert einfach nicht...
Wo liegt der Haken?

Christian


Complete thread:

 RSS Feed of thread