I have a form (PEAR::QF) with one field for entry of client or job#. Since client code is in job# I use one field only. Field element is a select so if it were only the client I were selecting I would:
[php]
$sql = "SELECT CONCAT(cust_id, ' ', company) AS name FROM $table_name
$clresult = @mysql_query($sql,$connection) or die;
while ($row = mysql_fetch_array($clresult)) {
$client_data[$row['name']] = $row['name'] ;
}
[PHP]
This works fine. However, to combine client and jobs, which structure is different, I use:
[php]
$sql = "SELECT cust_id, cust_id AS jobno, company AS descr
FROM $table1
UNION ALL
SELECT cust_id, jobno,descr
FROM $table2 " ;

$clresult = @mysql_query($sql,$connection) or die;
while ($row = mysql_fetch_array($clresult)) {
$client_job = $row['jobno'] ;
$client_descr = $row['descr'] ;
}
[PHP]

Since the structure is different if I try to CONCAT the fields from $table1 as name and CONCAT the fields from $table2 as name then the query fails.

How can I build an array as shown in the first query for the select element from the second query.