For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > May 2005 > direct way to handle mysql result sets (via resource id) with smarty









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author direct way to handle mysql result sets (via resource id) with smarty
Jörg Hermsdorf

2005-05-02, 4:00 pm

Hello List,
I would like to know if there is an easier way to
handle MySQL result sets in smarty? Currently I only
know of the approach to prepare an array out of the
resource id returned by mysql_query() :

....
$result = mysql_query('SELECT * FROM ...');
while ($row = mysql_fetch_assoc($result))
{
$result_array[] = $row;
}
$smarty->assign('results', $result_array);

Then I can use the result set within the {foreach
item=result from=$result_array}{/foreach} function.

But I'm looking for another way, where I can directly
assign the resource like this:

$smarty->assign('results', mysql_query('SELECT * FROM
....'));

.... is there a foreach-like smarty-plugin-function
that can handle a "resource id" instead of an array?

Thanks, Jörg.






________________________________________
___________________
Gesendet von Yahoo! Mail - Jetzt mit 250MB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com