Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving Trouble Outputting Data correctly From SQL Table
    text
    copied!<p>I am trying to outputting data from a SQL table </p> <p>Table cols are:</p> <p>sheduleID, userID, empID, timeSlot, WeekSlot, daySlot</p> <hr> <p>Connecting to DB</p> <pre><code>$schedQ = "SELECT * FROM seo_schedule WHERE empID=1 AND weekSlot=1"; $Em1Wk1Res = mysql_query($schedQ) or die(mysql_error()); </code></pre> <hr> <p>Displaying Data</p> <pre><code>echo "&lt;div class='week1'&gt;"; while ($Em1WkRow = mysql_fetch_array($Em1Wk1Res)) { $clientQ = "SELECT * FROM clients WHERE userID=".$Em1WkRow["userID"].""; $clientRes = mysql_query($clientQ) or die(mysql_error()); $clientRow = mysql_fetch_array($clientRes); echo "&lt;div class='day".$Em1WkRow["daySlot"]."'&gt;"; if ($Em1WkRow["timeSlot"] == "am") { echo "&lt;span class='".$Em1WkRow["timeSlot"]."'&gt;"; echo $clientRow["company"]; echo "&lt;/span&gt;"; } else if ($Em1WkRow["timeSlot"] == "pm") { echo "&lt;span class='".$Em1WkRow["timeSlot"]."'&gt;"; echo $clientRow["company"]; echo "&lt;/span&gt;"; } echo "&lt;/div&gt;"; } echo "&lt;/div&gt;"; </code></pre> <hr> <p>Current Output</p> <pre><code>&lt;div class="week1"&gt; &lt;div class="day1"&gt; &lt;span class="am"&gt;Company 1&lt;/span&gt; &lt;/div&gt; &lt;div class="day1"&gt; &lt;span class="pm"&gt;Company 1&lt;/span&gt; &lt;/div&gt; &lt;div class="day2"&gt; &lt;span class="am"&gt;Company 2&lt;/span&gt; &lt;/div&gt; &lt;div class="day2"&gt; &lt;span class="pm"&gt;Company 2&lt;/span&gt; &lt;/div&gt; ...etc fir rest of days in week 1 &lt;/div&gt; </code></pre> <hr> <p>What I want to be displayed is: </p> <pre><code>&lt;div class="week1"&gt; &lt;div class="day1"&gt; &lt;span class="am"&gt;Company 1&lt;/span&gt; &lt;span class="pm"&gt;Company 1&lt;/span&gt; &lt;/div&gt; &lt;div class="day2"&gt; &lt;span class="am"&gt;Company 2&lt;/span&gt; &lt;span class="pm"&gt;Company 2&lt;/span&gt; &lt;/div&gt; ...etc fir rest of days in week 1 &lt;/div&gt; </code></pre> <p>How do I go about doing this....? </p>
 

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