title: Using SET in mysqli query
body: <p>I've got this query to work in the editor but now that I transfer the Code into the table code I can't seem to get it to work...</p>
  <p>Is there something I'm doing wrong in order for this to work in the php?</p>
  <p>Having never used the SET in a mysql query before I assume it has something to do with this, I've tried moving the SET part to separate it to no avail but not sure whether it's just something really simple that I'm missing?</p>
  <pre><code>&lt;table data-role=&quot;table&quot; id=&quot;table-column&quot; data-theme=&quot;f&quot; data-mode=&quot;table&quot; class=&quot;ui-responsive table-stroke table-stripe&quot;&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th style=&quot;text-align: center&quot; data-priority=&quot;persist&quot;&gt;Date Recorded&lt;/th&gt;
                      &lt;th style=&quot;text-align: center&quot; data-priority=&quot;1&quot;&gt;Max Temp C°&lt;/th&gt;
                      &lt;th style=&quot;text-align: center&quot; data-priority=&quot;1&quot;&gt;rH%&lt;/th&gt;
                      &lt;th style=&quot;text-align: center&quot; data-priority=&quot;2&quot;&gt;Hours&lt;/th&gt;
                      &lt;th style=&quot;text-align: center&quot; data-priority=&quot;2&quot;&gt;Hours Running Total&lt;/th&gt;
                      &lt;th style=&quot;text-align: center&quot; data-priority=&quot;persist&quot;&gt;pH&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                  &lt;tr&gt;
                      &lt;?php
                          if (mysqli_connect_errno())
                            {
                            echo &quot;Failed to connect to MySQL: &quot; . mysqli_connect_error();
                            }
  
                           $result = mysqli_query($link, &quot;SET @runtot:= 0;
  SELECT   q1.dated, max_temp, max_rh, q1.c, (@runtot := @runtot + q1.c) AS rt
  FROM
  (SELECT datestamp AS dated,
     max_temp,
     max_rh,
     sum(hours) AS c,
     ph
  FROM hours
  WHERE hours &gt; 0 AND username = '$_SESSION[USERNAME]' AND batch_no = '$_SESSION[batch_no]'
  GROUP BY dated
  ORDER BY dated) AS q1&quot;);
  
  
                          if (!$result) {
                              die(&quot;Query to show fields from table failed&quot;);
                          }
                          $fields_num = mysqli_num_fields($result);
                          for($i=0; $i&lt;$fields_num; $i++)
                          {
                              $field = mysqli_fetch_field($result);
                          }
                          while($row = mysqli_fetch_row($result))
                          {
                      ?&gt;
                      &lt;td style=&quot;text-align: center; vertical-align: middle&quot;&gt;&lt;?php echo &quot;$row[0]&quot;?&gt;&lt;/td&gt;
                      &lt;td style=&quot;text-align: center; vertical-align: middle&quot;&gt;&lt;?php echo &quot;$row[1]&quot;?&gt;&lt;/td&gt;
                      &lt;td style=&quot;text-align: center; vertical-align: middle&quot;&gt;&lt;?php echo &quot;$row[2]&quot;?&gt;&lt;/td&gt;
                      &lt;td style=&quot;text-align: center; vertical-align: middle&quot;&gt;&lt;?php echo &quot;$row[3]&quot;?&gt;&lt;/td&gt;
                      &lt;td style=&quot;text-align: center; vertical-align: middle&quot;&gt;&lt;?php echo &quot;$row[4]&quot;?&gt;&lt;/td&gt;
                      &lt;td style=&quot;text-align: center; vertical-align: middle&quot;&gt;&lt;?php echo &quot;$row[5]&quot;?&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;?php
                      }
                      mysqli_free_result($result)
                  ?&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;
  </code></pre>