collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: requesting help with the news module.  (Read 1917 times)

0 Members and 1 Guest are viewing this topic.

Offline catolh

  • BeBot Rookie
  • *
  • Posts: 6
  • Karma: +0/-0
requesting help with the news module.
« 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.

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: requesting help with the news module.
« Reply #1 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);
}

?>

Offline catolh

  • BeBot Rookie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: requesting help with the news module.
« Reply #2 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!
« Last Edit: January 16, 2009, 08:35:20 pm by catolh »

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: requesting help with the news module.
« Reply #3 on: January 18, 2009, 01:44:24 am »
Change:  $SQL = "SELECT * FROM news";

To: $SQL = "SELECT * FROM news ORDER BY time DESC";
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 671
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal