View Full Version : Fetch post?
MarkFoster
05-30-2009, 10:05 PM
Is there anyways, whatsoever. That I will be able to fetch a post from the forums and put it on a custom page?
Like a code for this specific message?
Lynne
05-30-2009, 10:15 PM
Sure, with a query. If you have the postid, just make a query to the database for the message text. Just look up the query in showpost.php (the page for grabbing a single post (https://vborg.vbsupport.ru/showpost.php?p=1820318&postcount=1), like you mentioned)
MarkFoster
05-30-2009, 10:29 PM
Sure, with a query. If you have the postid, just make a query to the database for the message text. Just look up the query in showpost.php (the page for grabbing a single post (https://vborg.vbsupport.ru/showpost.php?p=1820318&postcount=1), like you mentioned)
If I'm not wrong you mean the vBulletin CP function called "Execute SQL Query", right?
However I'm not good at this. Or knowing. Are you telling me I have to make a code via looking at the "showpost.php" and put it through the SQL thing and then put it in the template?
I'd rather get a little more help here, please :)
Lynne
05-30-2009, 10:42 PM
Yes, I am saying you will have to do the "SQL thing" in order to grab the post. I'm suggesting you look in the showpost.php page because they used the same query there that you will need to use.
MarkFoster
05-30-2009, 10:51 PM
Yes, I am saying you will have to do the "SQL thing" in order to grab the post. I'm suggesting you look in the showpost.php page because they used the same query there that you will need to use.
I looked at the showpost.php. Three times. But I'm not sure what I should take. I'm sorr.y I'm just not any good at this.
--------------- Added 1243728398 at 1243728398 ---------------
It's really hard for me to figure out.
Could it possibly be related to this?
if ($postbit_obj->cachable)
{
/*insert query*/
$db->shutdown_query("
REPLACE INTO " . TABLE_PREFIX . "postparsed (postid, dateline, hasimages, pagetext_html, styleid, languageid)
VALUES (
$post[postid], " .
intval($threadinfo['lastpost']) . ", " .
intval($postbit_obj->post_cache['has_images']) . ", '" .
$db->escape_string($postbit_obj->post_cache['text']) . "', " .
intval(STYLEID) . ", " .
intval(LANGUAGEID) . "
)
");
}
Lynne
05-31-2009, 01:08 AM
I hate to tell you, but it's the big huge one that starts on line 124. That is the basic query that gets *everything* needed to spit out the post - the post itself, the userinfo regarding the person who posted it, the sig, the avatar, etc.... You never said how much of the post you want - just the message text? If so, you can get rid of anything there regarding userinfo/avatar/signature/spamlog/userfield/editlog/sigparsed/usertextfield.
Dismounted
05-31-2009, 03:53 AM
SELECT *
FROM post AS p
LEFT JOIN user USING (userid)
LEFT JOIN userfield USING (userid)
WHERE p.postid = X
That will fetch one specific post and associated user data. Note that the post will not have been parsed for BB code. If you have the knowledge/time, you may want to investigate fetching the cached post if available.
MarkFoster
05-31-2009, 04:25 AM
SELECT *
FROM post AS p
LEFT JOIN user USING (userid)
LEFT JOIN userfield USING (userid)
WHERE p.postid = X
That will fetch one specific post and associated user data. Note that the post will not have been parsed for BB code. If you have the knowledge/time, you may want to investigate fetching the cached post if available.
Okay. So lets say I put this in my SQL:
SELECT *
FROM post AS p
LEFT JOIN user USING (userid)
LEFT JOIN userfield USING (userid)
WHERE p.postid = 12066
Then what's the code I have to use to make it appear on the page?
Dismounted
05-31-2009, 06:18 AM
Providing you use query_first() to perform the query, all the data is inside the variable you assign it to. Open up the post table in phpMyAdmin (or similar) and see the structure.
MarkFoster
05-31-2009, 06:32 AM
Providing you use query_first() to perform the query, all the data is inside the variable you assign it to. Open up the post table in phpMyAdmin (or similar) and see the structure.
I'm not good at this. I tried to look for something but I couldn't. Anymore help with be appreciated.
Lynne
05-31-2009, 06:01 PM
You would go something like:
$myvariable = $db->query_first("SELECT *
FROM post AS p
LEFT JOIN user USING (userid)
LEFT JOIN userfield USING (userid)");
WHERE p.postid = 12066
and then you may use $myvariable['whatever'] in your page. You may have to do something to format it first. Take a look at how they do it in the script I mentioned.
MarkFoster
06-05-2009, 10:52 AM
You would go something like:
$myvariable = $db->query_first("SELECT *
FROM post AS p
LEFT JOIN user USING (userid)
LEFT JOIN userfield USING (userid)");
WHERE p.postid = 12066
and then you may use $myvariable['whatever'] in your page. You may have to do something to format it first. Take a look at how they do it in the script I mentioned.
t's been a few days. I've been tried to figure out what to do. But I can't.
I use this (https://vborg.vbsupport.ru/showthread.php?t=62164). Any extra help here?
Lynne
06-05-2009, 02:32 PM
The only way we can help is if you post your code so we can see exactly what you've done (use the html/php tags) and give us a link to the page so we can see the results.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.