Sunday, 15 January 2012

php - Getting actual Field name and Value : Simplified ver -



php - Getting actual Field name and Value : Simplified ver -

let have 3 tables: standard_code , study , transactions.

standard_code table field name: code

     values are: opening_balance, ending_balance, actual_remaining_balance

report table field names: opening_balance, ending_balance, actual_remaining_balance

you might think why kind of duplicates? well, technically different since 'standard_code' table has row values in 'report' columns , fixed , can't changed.

$sql = "select t.code, t.amount transactions t inner bring together standard_code sc on t.code = sc.code";

$result = mysql_query($sql);

while($row = mysql_fetch_assoc($result)) {

foreach ($row $col => $val) { echo $col." = ".$val."<br />"; }

sqlquery = "update study set '" . fieldname . "' = " . value ;

}

supposedly, during while or foreach loop how query update study table:

fieldname : code value standard_code table (the value here actual field names of study table)

value : transactions table : amount

both don't know how work base of operations on requirement.

my reason: have special requirements deals study specially on value placement/ formatting etc.. in short study complicated why created custom study table can study info format.

$sql = "select t.code, t.amount transactions t inner bring together standard_code sc on t.code = sc.code"; $result = mysql_query($sql); $q = array(); while($row = mysql_fetch_assoc($result)) { $q[] = $row['code'].' = '.$row['amount']; } // update study set opening_balance = 2, ending_balance = 2, actual_remaining_balance = 2 mysql_query('update study set '.join(', ', $q));

php mysql mysqli

No comments:

Post a Comment