?
Solved

PHP : how to assign variable from mysql to smarty

Posted on 2008-10-24
1
Medium Priority
?
525 Views
Last Modified: 2013-12-13
hi, i want to pull 1 column of data from mysql and put it into
smarty template that use

listmenu or html_option

 i have something like this

====================================================================================
$query = "SELECT * FROM package";
$query_result = @mysql_query ($query) OR error(mysql_error());
while ($info = @mysql_fetch_array($query_result))
{
      $types_temp = array();
      
      $types_temp = $info['pack_name'];

}

STemplate::assign('types_temp', $types_temp);
=================================================================================

TPL:
            <select name="package">
             <option value='null'>-- none --</option>
            {html_options options=$packnamez.sohai }
           </select>


does my TPL correct? i cant figure it work :(
some 1 please help
0
Comment
Question by:alicca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
hampus_b earned 2000 total points
ID: 22802787
see below. First, you have to add every row to array by assinging to $types_temp[] (note the []).
Then assign that variable and finally use it in smarty.
$query = "SELECT * FROM package";
$query_result = @mysql_query ($query) OR error(mysql_error());
while ($info = @mysql_fetch_array($query_result))
{
      $types_temp = array();
      
      $types_temp[] = $info['pack_name'];
 
}
 
STemplate::assign('types_temp', $types_temp);
=================================================================================
 
TPL:
            <select name="package">
             <option value='null'>-- none --</option>
            {html_options options=$types_temp }
           </select>

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question