thoma

Anonymous
Hi,

I created a static page wich does what I want with the below PHP. (Thanks Marc)

Only problem is I want it on the right hand column not in the center. I'm assumng this requites creation of a block by putting the below script into custom lib.php. Tried it but couldn't get it to work any help would be appreciated.


$numStories = 10;

$result = DB_query("Select sid, title,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE (date
$nrows = DB_numRows($result);

for ($i = 1; $i
$A = DB_fetchArray($result);

$retval .= date("M d",$A['day']) . ' -- ' . stripslashes($A['title']) . '
';

}

return $retval;


Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
Should be doable as a PHP block. Did you name the function correctly for use as a PHP block?

thoma

Anonymous
I used this-

Text Formatted Code
function phpblock_stories()
{

$numStories = 10;

$result = DB_query("Select sid, title,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE (date

$nrows = DB_numRows($result);

for ($i = 1; $i

$A = DB_fetchArray($result);

$retval .= date("M d",$A['day']) . ' -- <a href="' . $_CONF['site_url'] . '/article.php?story=' . $A['sid'] . '">' . stripslashes($A['title']) . '</a><BR>';

}

return $retval;

}
 

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Part of your code was eaten by our HTML filter. Use the forum's CODE button next time. And it would help if you could be more specific when describing your problem ...

Looks like you're missing a

global $_TABLES;

statement at least.

bye, Dirk

thoma

Anonymous
Thanks Dirk,

Do you know if I have to add more than $_TABLES ?

How do I would I know what to add?

Mike

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
If you can't get it to work, post your code again (using the CODE button this time) so someone can have a look.

bye, Dirk

thoma

Anonymous
ERROR

Matching CODE tag missing. Unable to format message.


thoma

Anonymous
I'm taking the code from the older stories thread:

http://www.geeklog.net/comment.php?mode=display&format=threaded&order=ASC&pid=12286

I will still try to put the code in the next message.

thoma

Anonymous
Text Formatted Code
$numStories = 10;
    $result = DB_query("Select sid, title,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0) ORDER BY date DESC LIMIT $numStories");
    $nrows = DB_numRows($result);
    for ($i = 1; $i <= $nrows; $i++) {
        $A = DB_fetchArray($result);
        $retval .=  date("M d",$A['day']) . ' -- <a href="' . $_CONF['site_url'] . '/article.php?story=' . $A['sid'] . '">' . stripslashes($A['title']) .  '</a><BR>';
}
    return $retval;

 

thoma

Anonymous
I would like to know if I need to add more than:

function phpblock_stories()
{

global $_TABLES;

to the above script I posted in the last email.

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
global $_CONF, $_TABLES;

from what I can see. Did you try it?

bye, Dirk

thoma

Anonymous
yeah it works thanks very much.