View Single Post
  #4  
Old 05-24-2007, 10:05 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: I have about had it! I need some help

Think of it as a heirarchy:

MYSQL DATABASE
- PHP
-- SMARTY
--- HTML BROWSER

When you want information from the database, you query it from the database in php, then you pass it to the smarty templates, which are rendered to display html in the browser.

So if you want a CustomerName variable, in your php file you use:

Code:
$CustomerName = func_query_first_cell("SELECT firstname FROM $sql_tbl['customers'] WHERE login='$login'");

The $login variable is unique for each person who is logged in to your site, so php uses this unique variable to query the persons actual name.

The func_query_first_cell is a built in x-cart function to query one cell from a record. Other common query calls include "func_query_first (get one record)" and "func_query (get multiple records)".

You then need to pass the variable to smarty, which is done in php with:

Code:
$smarty->assign("CustomerName",$CustomerName);

In your smarty templates, you can then use:

Code:
Hello {$CustomerName}.
Reply With Quote