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!
|
|
|
|