title: Echo data from two different tables in database: echo data 2nd table not working
body: <p>I want to echo some data from 2 tables of my database but the data of my second table "images" won't show up.</p>
  
  <p><strong>What I got:</strong></p>
  
  <ul>
  <li>1 database (no connection problem so that's fine)</li>
  <li>2 tables:
  
  <ul>
  <li>"articles" , columns (id, title, text)</li>
  <li>"images" , columns (idimage, image-title, image-path)</li>
  </ul></li>
  <li>I want to display data from those two tables on one webpage</li>
  <li>within the div "content-text", I need to display some images from the second table "images"</li>
  </ul>
  
  <p><strong>The webpage:</strong></p>
  
  <pre><code>&lt;div id="wrapper"&gt;
  
      &lt;?php
      include_once $_SERVER["DOCUMENT_ROOT"] . "/config.php";
      $title = str_replace ('-', ' ', $_GET['title']);
      $sql = "SELECT * FROM `articles` WHERE title = '$title'";
      $result = $conn-&gt;query($sql);
  
      if ($result-&gt;num_rows &gt; 0) {
      while($row = $result-&gt;fetch_assoc()) {
      ?&gt;
  
      &lt;div class="content-title"&gt;
          &lt;?php echo $row['title'];?&gt;
      &lt;/div&gt;
  
      &lt;div class="content-text"&gt;
          &lt;?php echo $row['text'];?&gt;
  
          &lt;?php 
          $imagesql = "SELECT * FROM `images` WHERE image-title = '$title'";
          $imageresult = $conn-&gt;query($imagesql);
          if ($imageresult-&gt;num_rows &gt; 0) {
          while($imagerow = mysqli_fetch_array($imageresult)) {
          ?&gt;
  
          &lt;a class="swipebox" href="&lt;?php echo $imagerow['image-path'];?&gt;" title="&lt;?php echo $imagerow['image-title'];?&gt;"&gt;
          &lt;img alt="image" src="&lt;?php echo $imagerow['image-path'];?&gt;"&gt;&lt;/a&gt;
  
          &lt;?php
          }// end while
          }// end if
          else {
          echo '0 results';
          }// end else
          ?&gt;
  
      &lt;/div&gt; //end content-text
  
      &lt;br&gt;
      &lt;?php
      }// end while
      }// end if
      else {
      echo '0 results';
      }// end else
      ?&gt;
  
      &lt;?php
      // close the connection
      $conn-&gt;close();
      ?&gt;
  
  &lt;/div&gt; // end wrapper
  </code></pre>
  
  <p><strong>The exact problem:</strong></p>
  
  <p>Echo the title and text from the table "articles" works fine, but there's something wrong when I try to echo the data from the table "images" cause it gives me the error "0 results". PHP and SQL is still new to me and I didn't manage to find the solution for this...</p>