PDA

View Full Version : How can I fetch a post?


MarkFoster
10-26-2009, 07:09 PM
How can I fetch a post to put on my custom page liek this:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions</title>
$headinclude
</head>
<body>
$header

$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%">
<table class="tborder" id="group0" cellpadding="6" cellspacing="1" border="0" width="100%">
<thead>
<tr>
<td class="tcat" colspan="3" rowspan="3"></td>
</tr>
</thead>
<tr>
<td class="alt2Active" id="u15" width="25%">

<!-- Image for game -->
<div>
<p>
<font size="1" face="Verdana">
<center>
<img src="" width="200" height="250">
<br></center>
<br><b>Title:</b>
<br><b>Console:</b> XBox 360
<br><b>Genre:</b> Beat 'em up<br><b>Players:</b> 1
<br>
<br><b>Release dates:</b>
<br>North America:
<br>Europe:
<br>Japan:
</font>
</p>
</div>
</td>

<td class="alt1" width="75%" >

[B]FETCHED POST HERE!

</div>
</td>
</table>

$footer
</body>
</html>

Lynne
10-26-2009, 08:11 PM
You would have to write a query to grab the post. I assume you have a php page to go along with that template, so you would put the query into the php page.

MarkFoster
10-27-2009, 12:29 PM
You would have to write a query to grab the post. I assume you have a php page to go along with that template, so you would put the query into the php page.

I absolutely have no experience with query's. I assume I put this inside my PHP file for the page:
SELECT *
FROM post AS p
LEFT JOIN user USING (userid)
LEFT JOIN userfield USING (userid)
WHERE p.postid = 12066
but I need to know exactly where to place the code on the PHP page. I use this: https://vborg.vbsupport.ru/showthread.php?t=62164

And not only that, I'm pretty sure the post odesn't "jump" up on the page on it's own. I'm pretty sure I need to add soem type of code in the template as well.

I hope you can help me. :)

Lynne
10-27-2009, 02:48 PM
You would put the query after it says "Start Main Page".... or basically after the global.php page is included and before the template is evaled. You can see what a query should look like by looking at other modifications or in the vbulletin php pages. You just need to use the query_first type of query (like I said, look it up in the vbulletin php pages). Really, the best way to learn how to do this is to see how it is done in vbulletin or a modification.

paul41598
10-27-2009, 04:05 PM
yup, run your select query, and then do something like a:

eval('$variablebits .= "' . fetch_template('template_name') . '";');

with all your data in the template.

ragtek
10-27-2009, 05:51 PM
I absolutely have no experience with query's. I assume I put this inside my PHP file for the page:
SELECT *
FROM post AS p
LEFT JOIN user USING (userid)
LEFT JOIN userfield USING (userid)
WHERE p.postid = 12066
but I need to know exactly where to place the code on the PHP page. I use this: https://vborg.vbsupport.ru/showthread.php?t=62164

And not only that, I'm pretty sure the post odesn't "jump" up on the page on it's own. I'm pretty sure I need to add soem type of code in the template as well.

I hope you can help me. :)

You could use fetch_postinfo($postid)!

$post = fetch_postinfo($postid);