BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => AO 0.6 support => Topic started by: catolh on January 16, 2009, 05:08:00 pm

Title: requesting help with the news module.
Post by: catolh on January 16, 2009, 05:08:00 pm
Hello there.

i am trying to get the contents in my news module printed on a web-page with the same formatting it has ingame.

I've tried forever but it just fails. I got the news printed on the page with this:

Code: [Select]

<?PHP

$user_name = "<user>";
$password = "<pass>";
$database = "<db>";
$server = "<server>";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);

if ($db_found) {

$SQL = "SELECT * FROM news";
$result = mysql_query($SQL);

while ($db_field = mysql_fetch_assoc($result)) {
print $db_field['news'] . "<BR>";

}

mysql_close($db_handle);

}
else {
print "Database NOT Found ";
mysql_close($db_handle);
}

?>



But it was just unformatted.
Title: Re: requesting help with the news module.
Post by: Temar on January 16, 2009, 07:13:20 pm
Code: [Select]
<?PHP

$user_name = "<user>";
$password = "<pass>";
$database = "<db>";
$server = "<server>";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);

if ($db_found) {

$SQL = "SELECT * FROM news";
$result = mysql_query($SQL);

$inside .= "<center><font color=#DDDD44>:::: News ::::</font></center><br>";
while ($db_field = mysql_fetch_assoc($result))
{
$inside .= "<font color=#00DD44>On " . gmdate("F jS, Y H:i", $db_field['time']) . " GMT <font color=#D9D9D2>" . $db_field['name'] . "</font> Reported:<br>";
$inside .= "<font color=#66AA66>" . stripslashes($db_field['news']);
$inside .= "<br><br>";
}
echo $inside;
mysql_close($db_handle);

}
else {
print "Database NOT Found ";
mysql_close($db_handle);
}

?>
Title: Re: requesting help with the news module.
Post by: catolh on January 16, 2009, 08:16:17 pm
Omg, awesome! It worked like a charm :D

Thanks alot for the help!

One more thing though (i dont want to sound ungrateful or anything), is it possible to get it inverted? It shows first posted first, and newest news on the bottom. Is it possible to sort this in any way? or invert it somehow?

*edit*

Got it to work, just copied the code from news.php. But thanks again! awesome work!
Title: Re: requesting help with the news module.
Post by: Getrix on January 18, 2009, 01:44:24 am
Change:  $SQL = "SELECT * FROM news";

To: $SQL = "SELECT * FROM news ORDER BY time DESC";
SimplePortal 2.3.7 © 2008-2024, SimplePortal