Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To start, your code that generates the <em>year</em> fields has a nice syntax error:</p> <pre><code>"SUM(IF(c.datecreated='".$year."',IF(LOWER(c.fullTimeEployeeType)='basic hour rate', c.fullTimeEployeeTypeAmount*2080 , c.fullTimeEployeeTypeAmount),0) ".$year."," </code></pre> <p>The <code>SUM(</code> opening statement is missing a closing parentheses. On top of that, you have a floating <code>".$year."</code> that isn't part of any of the enclosed methods (though, it could be used as an alias; I'm not used to seeing it without a preceeding <code>AS</code> though - so this could be my mistake). To take a guess, I would say to replace the <code>".$year."</code> with a <code>)</code> and that should fix that part:</p> <pre><code>$concatYear .= "SUM(IF(c.datecreated='".$year."',IF(LOWER(c.fullTimeEployeeType)='basic hour rate', c.fullTimeEployeeTypeAmount*2080 , c.fullTimeEployeeTypeAmount),0)),"; </code></pre> <p>If the <code>$year</code> addition is in fact to be an alias, you could add the closing parentheses immediately before it to close the <code>SUM()</code> function.</p> <p>Regarding dynamically binding the variables, my ideal solution actually comes from <a href="https://stackoverflow.com/questions/5300365/dynamically-bind-mysqli-stmt-parameters-and-then-bind-result-php">a similar question/answer</a> on SO (this is a direct copy/paste and I take no credit for it, but I do like it =P):</p> <pre><code> // Get metadata for field names $meta = $stmt-&gt;result_metadata(); // This is the tricky bit dynamically creating an array of variables to use // to bind the results while ($field = $meta-&gt;fetch_field()) { $var = $field-&gt;name; $$var = null; $fields[$var] = &amp;$$var; } // Bind Results call_user_func_array(array($stmt,'bind_result'),$fields); // Fetch Results $i = 0; while ($stmt-&gt;fetch()) { $results[$i] = array(); foreach($fields as $k =&gt; $v) $results[$i][$k] = $v; $i++; } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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