class design - improving a view_html class
<p>This class provides user created content to the page.</p>

<p>The call is made from html like this:</p>

<pre><code>  &lt;?php new route('tweets'); ?&gt;
</code></pre>

<p>or</p>

<pre><code>  &lt;?php new route('bookmarks'); ?&gt;
</code></pre>

<p>Route instantiates view_html and passes the paramter along.</p>

<p>What improvments that can be made?</p>

<pre><code>/*view_html*/

class view_html extends database
  {
  function __construct($type)
    {
    parent::__construct();    
    switch ($type) 
      {
      case "bookmraks":
        $this-&gt;bookmarks();
        break;
      case "tweets":
        $this-&gt;tweets();
        break;
      default:
        echo "Invalid View Type";
        break;
      }
    }
  private function bookmarks()
    {
    $email = $_SESSION['email'];
    $query_return = database::query("SELECT * FROM bo  WHERE email='$email' ORDER BY name ASC");
    while ($ass_array = mysqli_fetch_assoc($query_return))
      {
      $fav=$this-&gt;fav($ass_array['url']);
      echo "&lt;img name=\"bo_im\" class=\"c\" src=\"$fav\"/ onerror=\"i_bm_err(this)\"&gt;&lt;a target=\"_blank\" name = \"a1\" class = \"b\" href = \"$ass_array[url]\"&gt;$ass_array[name]&lt;/a&gt;";
      }      
    }
  private function tweets() 
    {
    $query_return = database::query("SELECT * FROM tw ORDER BY time DESC LIMIT 7");
    $time = time();
    while ($a = mysqli_fetch_assoc($query_return))
      {
      echo  "&lt;div class=\"Bb2b\"&gt;&lt;img class=\"a\" src=\"p/$a[email].jpg\" alt=\"\"/&gt;&lt;a class=\"a\" href=\"javascript:void(0)\"&gt;$a[fname] posted &lt;script type=\"text/javascript\"&gt;document.write(v0($a[time],$time))&lt;/script&gt;&lt;/a&gt;&lt;br/&gt;&lt;p class=\"c\"&gt;$a[message]&lt;/p&gt;&lt;/div&gt;";
      }
    }
  private function fav($url)     
    {    
    $pieces = parse_url($url);    
    $domain = isset($pieces['host']) ? $pieces['host'] : '';    
    if(preg_match('/(?P&lt;domain&gt;[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs))       
      {     
      return $pieces['scheme'] . '://www.' . $regs['domain'] . '/favicon.ico';    
      }    
      return false;
    }
  }
</code></pre>
