title: Foreach Loop Only Displaying One Value From Array
body: <p>I have tried researching other questions similar to my problem, but I haven't found anything that addresses this specifically. I am selecting data using mysqli and displaying it in a table. The column <code>table_yard</code> can have multiple values, so I exploded those values and stored them as an array to be looped through and then stored the result in variable <code>$yard_name</code>. I later assign this variable to a row in my table like so (<code>$get</code> is storing the sql query):</p>
  
  <pre><code> while ($row = mysqli_fetch_assoc($get)) {
      $yards = explode(",", $row[table_yard]);
  foreach ($yards as $yard) {
      $yard_name = $yard . ", ";
  }
      $table_rows .= "&lt;tr&gt;
                  &lt;td&gt;" . mdy($row[table_date]) . "&lt;/td&gt;
                  &lt;td&gt;" . $yard_name . "&lt;/td&gt;
                  &lt;/tr&gt;";
  </code></pre>
  
  <p>The problem is, if there is more than one value in that array, it only displays the first item. I ran a debug on <code>$yards</code> to see if it was even getting all the values of the array, and it is, as shown here:</p>
  
  <pre><code>Array (
  [0] =&gt; 711
  [1] =&gt; 2793
  [2] =&gt; 988
  )
  </code></pre>
  
  <p>Although, this is what gets displayed in the <code>&lt;td&gt;</code> cell:</p>
  
  <pre><code>711, 
  </code></pre>
  
  <p>What I want it to display is this:</p>
  
  <pre><code>711, 2793, 988 
  </code></pre>
  
  <p>I am sure it's a rookie mistake, but I can't figure it out. Thank you in advance for any help.</p>