The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Running a Query in a template
I'd like to have the value of a query (SELECT...) or a function from within a template. Where's the best place for me to put it?
Should I put it in the .php file that calls the template? (I've seen some people put in their global include, but that is very wasteful of resources...) |
#2
|
||||
|
||||
"hook postbit_create"
$blah = $db->query_read("SELECT * FROM ") "filter results" $blah = '<a href="disney.com">' . $filtered . '</a>'; in the postbit template put $blah where you want the text to appear put the query in a hook and make the variable there... not sure this was the question |
#3
|
|||
|
|||
Quote:
What do you mean by "filter results"? |
#4
|
||||
|
||||
well
Code:
$result = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "user"); $a = ''; while( $user = $db->fetch_array( $result ) ) { $a .= "($user[username], userid $user[userid])<br />"; } if you want just the first row, you could use Code:
$user = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "user"); $a .= "($user[username], userid $user[userid])<br />"; |
#5
|
|||
|
|||
Thanks, got it.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|