title: Custom CMS how to create categories for posts with PHP/MySQL database
body: <p>I am searching all around the internet but I can't seem to find a simple tutorial that can help me with my custom CMS I am building. </p>
  
  <p>I'd like to add multiple categories to my posts.</p>
  
  <p>For example:</p>
  
  <pre><code>Title: post 1 
  Content: content goes here 
  Categories: Technology, Computers, Science, Internet
  
  Title: post 2 
  Content: content goes here 
  Categories: Music, Jazz, Classic
  </code></pre>
  
  <p>So this is what I have to post my articles</p>
  
  <p><strong>My database structure</strong></p>
  
  <pre><code>postID | postTitle | postDesc | postCont | postDate
  
  
  1   Post 1      info1   content1    date1
  2   Post 2      info2   content2    date2
  3   Post 3      info2   content3    date3
  </code></pre>
  
  <p><strong>The FORM</strong></p>
  
  <pre><code>&lt;form action='' method='post'&gt;
  
  &lt;p&gt;&lt;label&gt;Title&lt;/label&gt;&lt;br /&gt;
  &lt;input type='text' name='postTitle' value='&lt;?php if(isset($error)){ echo $_POST['postTitle'];}?&gt;'&gt;&lt;/p&gt;
  
  &lt;p&gt;&lt;label&gt;Description&lt;/label&gt;&lt;br /&gt;
  &lt;textarea name='postDesc' cols='60' rows='10'&gt;&lt;?php if(isset($error)){ echo $_POST['postDesc'];}?&gt;&lt;/textarea&gt;&lt;/p&gt;
  
  &lt;p&gt;&lt;label&gt;Content&lt;/label&gt;&lt;br /&gt;
  &lt;textarea name='postCont' cols='60' rows='10'&gt;&lt;?php if(isset($error)){ echo $_POST['postCont'];}?&gt;&lt;/textarea&gt;&lt;/p&gt;
  
  &lt;p&gt;&lt;input type='submit' name='submit' value='Submit'&gt;&lt;/p&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>the PHP code to place it in the database</strong></p>
  
  <pre><code>//insert into database
  $stmt = $db-&gt;prepare('INSERT INTO blog_posts (postTitle,postDesc,postCont,postDate) VALUES (:postImage, :postTitle, :postDesc, :postCont, :postDate)') ;
  $stmt-&gt;execute(array(
  ':postTitle' =&gt; $postTitle,
  ':postDesc' =&gt; $postDesc,
  ':postCont' =&gt; $postCont,
  ':postDate' =&gt; date('Y-m-d H:i:s')
  ));
  
  //redirect to index page
  header('Location: index.php?action=added');
  exit;
  </code></pre>