![]() |
How do I display a result of a query?
Well I'm trying to show the Results from a data base query in a templeat can any one tell me how to do this?
|
Quote:
Then just use $foo[foo] in the templates. |
I know how to do arrays but can you show me a exaple code my tables fields are:
id name url description |
$variable = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "tablename WHERE id = id");
$variable['id'] $variable['name'] $variable['url'] $variable['description'] |
thank you
That code cases errors anyone? |
help!
|
what error?????
|
I get:
Parse error: parse error, unexpected T_VARIABLE in /home/rdsx667/public_html/tutorials/test.php on line 55 EDIT: before this code there was no error ( This isn't suppose to sound rude) |
please disply your code to me. lines 50-60.
|
heres the code:
$variable = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "tablename WHERE 1 = Links"); $variable['id'] $variable['name'] $variable['url'] $variable['description'] eval('print_output("' . fetch_template('site_test') . '");'); |
lol, you have to put:
$variable['id'], $variable['name'], $variable['url'], $variable['description'] in your template (site_test). $variable['id'] would display the mysql field id as do the other variables have the sam operation. and with the query you need to change tablename to your mysql table name. ANd change 1 to a valid mysql field (i think this would be id, name, description, or url). |
I get this error when I save the templeat:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/rdsx667/public_html/forum/includes/adminfunctions_template.php(3537) : eval()'d code on line 18 |
Just to let you know. it's extremly hard for peole to help you if you don't post the code you're using when you list errors. When asking for help try to list the error and your code.
Remove the ' from the variables when putting them in vbulletin templates. |
sorry about this I'll try removing ' from it though.
It works with this thank you for the help. on more question and I'm done how do I make the code repeat for the resaults? |
you mean print the results for each row in the table?
|
yes, help much apprictated
|
PHP Code:
|
thanks for the help it is much apprcated.
|
No prob, glad to help.
|
All times are GMT. The time now is 02:20 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|