CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge -> Programming

 Select List uing PHP/MySQL in Code Charge

Print topic Send  topic

Author Message
paporter
Posted: 05/17/2004, 5:39 AM

I am wanting to use two fields concatenated with a dash between them as the displayed value of a select list. Below is the code I would use if I was hand coding this. How can I accomplish this effect in Code Charge?

I appreciate any assistance offered.

Paul


echo('<select name="Location">');

$query = "SELECT loc_id, building, area FROM equip_location ORDER by building asc";

$result = @mysql_query($query, $connection) OR die("Query Failed");

$id="loc_id";
$bldg="building";
$area="area";
$numrows = @mysql_num_rows($result);
if ($numrows > 0)
{

$y=0;
while ($y<$numrows)
{
$theId=mysql_result($result,$y,$id);
$theBldg=mysql_result($result,$y,$bldg);
$theArea=mysql_result($result,$y,$area);
echo "<option value=\"$theId\">$theBldg - $theArea</option>\n";
$y++;
}
}
echo "</select>";
[/CODE]
paporter
Posted: 05/17/2004, 1:04 PM

I got it taken care of. I would have rather found a way to do it inside CodeCharge but since I was under a time restraint what I ended up doing was going in and modifying the query string in the generated page and let MySQL deal with the problem.

Paul
CosmixXx
Posted: 06/21/2004, 8:08 PM

Sorry for the late - late rply , but i'll post it anyway for fun :)
its quite ez, u can achieve this by using the "Lookup SQL" in your particular "Field Properties" . Under the "List" tab
enter the custom query in the "Lookup SQL"; in your case will be :
"SELECT loc_id, concat(building,' - ', 'area') FROM equip_location ORDER by building asc"

as simple as that... :)
this is what i really love from the original CC
its simple yet really works!


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.

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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