CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Dynamic Listbox Values and Arrays

Print topic Send  topic

Author Message
datadoit
Posted: 12/01/2008, 5:34 AM

CCS 3.2; PHP5; MySQL5

Listbox values can be dynamically set via:

$Component->Values = array(array("1","one"), array("2","two"));

Easy enough. However, I need those values to come from the database.
Basically I need everything the wizard provides, but I need some
granular control over the values based on conditions. So here's where
I'm at:

<code>
$db = new DBConnection();
$sql = "SELECT extension FROM tbl_extensions WHERE whatever";
$db->query($sql);
while ($db->next_record()) {

**** Here's where those array values are populated. ****

}
$db->close();
</code>

How do I populate those array values to the listbox?

Thanks.
feha


Posts: 712
Posted: 12/01/2008, 7:06 AM

Below is if you have already an array :-)
  
	$my_box=array();  
if (is_array($my_array))  
{  
	foreach ($my_array as $key => $option)  
	{  
	$my_box []= array($key, $option);  
	}  
}  
  
// Listbox name of your component ...  
$Component->Listbox->Value= $my_box;  
in your case :
  
$my_box=array();  
$db = new DBConnection();  
$sql = "SELECT * FROM tbl_extensions WHERE whatever";  
$db->query($sql);  
while ($db->next_record()) {  
  
$my_box []= array( $db->f("key"), $db->f("option") );  
  
}  
$db->close();  
// populate your listbox ...  
$Component->Listbox->Value= $my_box;  
Always your's
feha

_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
datadoit
Posted: 12/01/2008, 9:16 AM

Of course, as usual, Feha is the guru!

Thanks!

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.