title: Data Driven Switch and Case PHP
body: <p>I am trying to figure out how to build a switch in php using links from a database using mysqli.</p>
  
  <p>Operative $d</p>
  
  <pre><code>if (isset($_GET['page'])) {
      $d = $_GET['page'];
  } elseif (isset($_POST['page'])) { // Forms
      $d = $_POST['page'];
  } else {
      $d = NULL;
  }
  </code></pre>
  
  <p>The Switch</p>
  
  <pre><code>$sw1 = "SELECT * FROM pages";
  $sw2 = mysqli_query($connection, $sw1);
  while($row = mysqli_fetch_assoc($sw2)) {
      $page = $row['page'];
  
      switch($d) {
  
      case ''.$page.'':
          include 'modules/'.$page.'.php';
          break;
  
      default:
          include 'modules/main.php';
          break;
        }
  }
  </code></pre>
  
  <p>This is not working, is there a different way to do this? idea is to allow URl's such as <code>/?page=thePage</code></p>
  
  <p><code>$connection</code> is handled and connection to the database is confirmed so that is not the issue.</p>
  
  <p>Any help is Greatly Appreciated.</p>