Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting actual Field name and Value : Simplified ver
    primarykey
    data
    text
    <p>Let say I have 3 tables: Standard_Code and Report and Transactions.</p> <blockquote> <p><strong>Standard_Code</strong> table field name: <strong>Code</strong> </p> <p>&nbsp;&nbsp; &nbsp; Values are: Opening_Balance, Ending_Balance, Actual_Remaining_Balance</p> <p><strong>Report</strong> table field names: Opening_Balance, Ending_Balance, Actual_Remaining_Balance</p> </blockquote> <p>You might think why would I do this kind of duplicates? Well, technically they are different since the 'Standard_Code' table has row values but in my 'Report' they are columns and they are fixed and can't be changed.</p> <blockquote> <p>$sql = "Select t.code, t.amount From Transactions t Inner Join Standard_Code sc on t.code = sc.code";</p> <p>$result = mysql_query($sql);</p> <p>while($row = mysql_fetch_assoc($result)) { </p> <pre><code> foreach ($row as $col =&gt; $val) { echo $col." = ".$val."&lt;br /&gt;"; } </code></pre> <p>sqlQuery = "Update Report Set '" . <strong>fieldname</strong> . "' = " . <strong>value</strong> ; </p> <pre><code>} </code></pre> </blockquote> <p>Supposedly, during the while or foreach loop how to do this query to update the Report table:</p> <p><strong>fieldname</strong> : <code>Code</code> value from Standard_Code table <em>(the value here are the Actual Field names of the Report table)</em></p> <p><strong>value</strong> : From Transactions table : <code>Amount</code></p> <p>both something I don't know how to work base on my requirement.</p> <p><strong>My reason:</strong> I have special requirements that deals with the report specially on value placement/ formatting etc.. in short the report is complicated that is why I created a custom Report table so I can easily get the report data to format.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload