Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 10:20 am EDT

Geeklog Forums

Static page for left hand column


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;

 Quote

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?
 Quote

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;

}
 
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
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
 Quote

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
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
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
 Quote

thoma

Anonymous
ERROR

Matching CODE tag missing. Unable to format message.

 Quote

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.
 Quote

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;

 
 Quote

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.
 Quote

Status: offline

Dirk

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

from what I can see. Did you try it?

bye, Dirk
 Quote

thoma

Anonymous
yeah it works thanks very much.
 Quote

All times are EDT. The time is now 10:20 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content