title: What is the best way to get Category-info and Article-info at same time from mysql/php?
body: <p>I am building a simple newspaper-site, due to schoolwork. I have two tables in my database. </p>
  
  <p><strong>Categories</strong>
  [CategoryID, CategoryName, ParentID (which points to cat.id)]</p>
  
  <p><strong>Article</strong>
  [ArticleID, Heading, Teasertext, Content, Date, Category(which is foreign key to CategoryID)]</p>
  
  <p>On the first page im pulling out the latest articles written, and below each article has to have a link to the article (which is based on index.php?name=CategoryName&amp;parent=ParentID). </p>
  
  <p>I need to withdraw the relevant info about CategoryName and ParentID from the Category-info in Articles-table.</p>
  
  <p>Im stuck on how to combine the two queries in to one. Im wondering if you have any idea´s on how to solve it? </p>
  
  <p>This is what I got. </p>
  
  <pre><code>function display_articles($link)
  {
  
      $result = mysqli_query($link, "SELECT * FROM Article ORDER BY Date DESC");
  
                  if (!$result)
                  {
                      $error = 'Error fetching Articles: ' . mysqli_error($link);
                      exit();
                  }
  
  
                  while ($row = mysqli_fetch_array($result))
                  {
                      $Heading[] = $row['Heading'];
                      $Teasertext[] = $row['Teasertext'];
                      $Date[] = $row['Date'];
                  }
  
  
                  if (isset($Heading))
                  {
                      for ($i=0; $i&lt;count($Heading); $i++)
                      {
  
                          echo '&lt;div class="frontpage"&gt;&lt;h2&gt;' .htmlspecialchars($Heading[$i], ENT_QUOTES, "UTF-8"). '&lt;/h2&gt;'; 
                          echo htmlspecialchars($Date[$i], ENT_QUOTES, "UTF-8");
                          echo '&lt;p class="Teasertext"&gt; ' .htmlspecialchars($Teasertext[$i], ENT_QUOTES, "UTF-8"). '&lt;/p&gt;&lt;/div&gt;';
                          echo '&lt;a href="index.php?name='                 
                      }
                  }
  
  }
  </code></pre>