You are here: Re: [SMARTY] html_options « Smarty Templates Posts « IT news, forums, messages
Re: [SMARTY] html_options

Posted by Jm on 05/13/05 19:11

Man this really burned a few brain cells but I got it with your help.
Thanks Thomas. Here's what I ended up with:

// Build job selector pulldown
$sql_job_pulldown = "SELECT Job, JobName FROM t_jobinfo;";

if($result = $mysqli->query($sql_job_pulldown))
{
// dump into a select statement
// fetch associative array
while($row = $result->fetch_assoc())
{
$options_job_name[$row["Job"]] = $row["JobName"];
$options_job[$row["Job"]] = $row["Job"];
}
$smarty->assign('OPTION_JOB_NAME', $options_job_name);
$smarty->assign('OPTION_JOB', $options_job);
$result->close();
}
else
{
// Send to results page
$results_page_message = "Query failed: " . $mysqli->error;
$smarty->assign('RESULTS_PAGE', $results_page_message);
include($_SERVER['DOCUMENT_ROOT'] . '/includes/results_page.php');
exit;
}



On 5/13/05, Thomas Pundt <mlists@rp-online.de> wrote:
> Hi,
>
> On Friday 13 May 2005 02:17, JM wrote:
> | I'm trying to build a select/option list off of a database select.
> | I've confirmed that the correct data is coming out of the query. My
> | options are empty in the template though. This is my first attempt at
> | html_options. I'm doing something wrong, any help? TIA
> |
> |
> | PHP:
> |
> | // Build job selector pulldown
> | $sql_job_pulldown = "SELECT Job FROM t_jobinfo;";
> |
> | if($result = $mysqli->query($sql_job_pulldown))
> | {
> | // dump into a select statement
> | // fetch associative array
> | $smarty->assign('JOB_OPTION', $result);
> | $result->close();
> | }
>
> $result is the database query handle - not an associative array, right?
>
> In case I use a {html_options} element I fill it using something like
> (using DB interface):
>
> while ( $row = $res->fetchRow() ) {
> $options[$row->key] = $row->value;
> }
>
> $template->assign('JOB_OPTION', $options);
>
> Best regards,
> Thomas Pundt
>
> --
> Dr. Thomas Pundt <thomas.pundt@rp-online.de> ---- http://rp-online.de/ ----
>
>


--
J

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация