![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
赤い靴 call me 202-456-1111
Industry Role:
Join Date: Feb 2001
Location: The Valley
Posts: 14,831
|
Who here knows Smarty? I have a quick question
according to this smarty doc, http://smarty.php.net/manual/en/config.files.php you can gain access to a mysql database.
And according to this doc, http://smarty.php.net/manual/en/api.config.load.php you can load those configs into the php file. But how do you tell the php which table to use within that database? I'm really new to php, smarty, and mysql. But from what I can gather in mysql and php, you connect to the mysql and then you connect to the table you want to call info from. So how do you do that with smarty? OR Is it better to just create a config file of an associative array of data? I asked that on the smarty board but after being on GFY for years all other boards move slow as shit.
__________________
SPECIALTY COSTUMES • PROPS • FX Superheroes • Monsters • Robots PM for details For any manufacturing needs. Adult or otherwise. aka BonsHigh on Insta Bonsai weed plants |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
赤い靴 call me 202-456-1111
Industry Role:
Join Date: Feb 2001
Location: The Valley
Posts: 14,831
|
n e one?
__________________
SPECIALTY COSTUMES • PROPS • FX Superheroes • Monsters • Robots PM for details For any manufacturing needs. Adult or otherwise. aka BonsHigh on Insta Bonsai weed plants |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Industry Role:
Join Date: Jun 2004
Location: New York, NY
Posts: 6,890
|
You really shouldn't be mixing php code into your smarty templates as the whole purpose of smarty is to separate code from html.
However Smarty has no mysql functions I know of, so to do it in the template you would have to use {php}{/php} to allow you to execte php code and then use php's mysql functions like mysql_connect(), mysql_db_query(), etc... I recommend since you are starting though to start the right way and use adoDB or another db abstraction layer class to keep things portable and clean. Do your SQL in the php file and assign it to whatever variables you need to access it with in smarty. Don't tdo your SQL in the template. ![]()
__________________
Skype variuscr - Email varius AT gmail |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
赤い靴 call me 202-456-1111
Industry Role:
Join Date: Feb 2001
Location: The Valley
Posts: 14,831
|
Quote:
Smarty prides itself on not needing mysql, and doesn't even offer a way to use mysql... so then how do you use databases? Can you even use databases? I want to create database of all our girls, and display them with Smarty and be able to sort them, and rate them, all that (in time). And I'm willing to kinda play with it and learn it myself, but I just don't see how you do that WITHOUT the use of mysql.
__________________
SPECIALTY COSTUMES • PROPS • FX Superheroes • Monsters • Robots PM for details For any manufacturing needs. Adult or otherwise. aka BonsHigh on Insta Bonsai weed plants |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 | |
Too lazy to set a custom title
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Industry Role:
Join Date: Jun 2004
Location: New York, NY
Posts: 6,890
|
Red,
Quick example to help you out: (this part is in your php file, assuming you already connected to the Db etc...) $sql = "SELECT field1, field2 FROM table"; $result = $db->GetAll($sql); // This is if you are using adodb $smarty->assign('result',$result); (this is how you loop through that data in your template) {section name=a loop=$result} <tr><td>whatever HTML here</td><td>{$result[a].field1}, {$result[a].field2}</td></tr> {/section} Hope that helps ![]()
__________________
Skype variuscr - Email varius AT gmail |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Too lazy to set a custom title
Industry Role:
Join Date: Jul 2001
Location: Currently Incognito
Posts: 13,827
|
You use smarty plugins. This allows you to create blocks of php that can do different functions, then call those functions to the template.
Often in /smarty/libs/plugins You normally don't have to mysql connect directly when using a plugin, but you can if you want to connect to a different db other than the local setup. As an example Code:
function smarty_function_getpassword($params, &$smarty) { $user = $_SERVER[PHP_AUTH_USER]; $result = mysql_query("SELECT * FROM members WHERE username = '$user'"); $password=$row["pass"]; $smarty->assign ($params['xpassword'], $password); return ($password); } Call it like: {getpassword values="xpassword"}
__________________
![]() ![]() ![]() It's all disambiguation ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |