DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • September 02, 2010, 09:46:48 AM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: [1]   Go Down
  Print  
Author Topic: Please help with news code  (Read 562 times)
0 Members and 1 Guest are viewing this topic.
egdcltd
Militia
**
Offline Offline

Posts: 77


View Profile WWW
« on: November 07, 2005, 04:59:34 AM »

I am trying to create a bit of php code that will display LOTGD news elsewhere on my site. I have done some code, but unfortunately the output is a bit scrambled due to the way news is stored in the database.

Code:
<?php
$username
="user";
$password="password";
$database="database";

@
mysql_connect('localhost',$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");
$query "SELECT * FROM lotgd_news ORDER BY newsid DESC LIMIT 0,3";
$result = @mysql_query($query)
or die (
"Couldn't execute query: " mysql_error());

echo 
"<b>Latest Legend of the Green Dragon News</b><br /><br />";

while (
$row mysql_fetch_array($result,MYSQL_ASSOC))
{
extract($row);
echo 
"$newstext<br /><br />";
}

?>


Output:

Latest Legend of the Green Dragon News

`%%s`5 has been slain in the forest by %s.`n%s

`%%s`5 has challenged their master, %s and lost!`n%s

`%%s`3 has defeated her master, `%%s`3 to advance to level `^%s`3 after `^%s`3 days!!

Can anyone tell me what changes I need to make to get the code to work properly. I know there is another column in the news table that contains the relevant information, but I do not know how to incorporate it.
Logged

XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #1 on: November 07, 2005, 05:11:56 AM »

in your while-loop do the following:

copy lines 54 to 65. Replace the translation part by the standard PHP sprintf()-function.

before outputting / echoing your news, have a close look at "lib/sanitize.php", especially lines 38 to 41.

This should give you the right direction to go... Wink

PS: All line numbers for 1.0.3

Logged

Running for more than three years now:
Dannic
Guest
« Reply #2 on: November 07, 2005, 07:19:28 PM »

if you can use an rss feed there is an rss module that will do this for you.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Who's Online
32 Guests, 0 Users
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search