php - How can I add other data after the resulting query -


i have query.

 $stmt = $this->getconnection()->prepare("select * detailuser id = ?"); $result = $stmt->fetchall(pdo::fetch_assoc); 

and want add amount in result after dateadded, confuse how add amount. amount in table , have no reference on first table (detailuser)

$amount = 100;

$rec = array(                 'data'=>$result,               );  echo json_encode($rec);  {"data":[{"firstname":"alex","friendname":"alice","amount_due":"600.00","dateadded" :"2015-09-14 13:30"},{"firstname":"annie","friendname":"karren","amount_due":"600 .00","dateadded":"2015-09-14 13:30"},{"firstname":"helen","friendname":"alice","amount_due":"600.00","dateadded":"2015-09-14 13:30"}]} 

thank in advance

you can prepare select statement fetch rows , in statement, can add dummy column.

select *, 100 'amount' table_name


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -