Welcome to Geeklog, Anonymous Monday, December 23 2024 @ 09:50 am EST

Geeklog Forums

Pull a story's title by its id


Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
Let's say I have a story id (and a topic id too, just in case it's needed).
What's the easiest way to just pull the story's title from the database into a PHP parameter?

Thanks!
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Text Formatted Code
$title = stripslashes (DB_getItem ($_TABLES['stories'], 'title', "sid = '$your_story_id'"));
 

Of course that doesn't check for any permissions ...

bye, Dirk
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
Thanks!

About the permissions, my script assumes you're already inside the topic (if either topicoption_off is active or (unlike topicoption_off) or if you're inside the topic's page X. It detects it from $_SERVER['QUERY_STRING']).

Now what if I don't have the article id, but I have the topic id and I know there's only 1 story per page.
Is there an easy way to know the titles of the story in the topic's page 1, the story in the topic's page 2, etc.?

Also, is there a way to know the overall stories in a topic (so I can run an automatic "for" loop that finds all of its stories' titles)?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
May I suggest spending some time with the database (specifically, the gl_stories and gl_topics tables)? It's not that hard to figure out ... Also, article.php and lib-common.php provide a lot of sample code.

bye, Dirk
 Quote

All times are EST. The time is now 09:50 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