title: how to convert the data returned from mysql database into json
body: <p>I am trying to learn backbone.JS using WAMP server. when I am trying to retrieve the data from database using fetch function, I couldn't convert the data extracted from database into JSON objects. So here I used Index.php for client side and views.php for server side. Name of my database is dss.Thanks in advance. So here is my code </p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>            &lt;!doctype html&gt;
              &lt;html&gt;
                  &lt;title&gt;
                      backbone example
                  &lt;/title&gt;
                  &lt;body&gt;
                      &lt;script src="jquery-1.9.1.js"&gt;&lt;/script&gt;
                      &lt;script src="underscore.js"&gt;&lt;/script&gt;
                      &lt;script src="backbone.js"&gt;&lt;/script&gt;
                      &lt;div id="container"&gt;
                      &lt;h1&gt;
                          HELLO
                      &lt;/h1&gt;
                          &lt;div id="page"&gt;
  
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;script&gt;
                          var User=Backbone.Collection.extend(
                              {
                                  url:'backbone sample/users'
                              }
                          );
                          var UserList=Backbone.View.extend(
                          {   
  
                              el:'#page',
                              render:function()
                              {
                                    var that=this;
                                  var users=new User;
  
                                          users.fetch({
  
                                              success:function()
                                              {
                                                      alert('success');
                                              }
                                      }
                              );
                                  }
                          }
                          );
                           var router=Backbone.Router.extend(
                           {
                               routes:
                                   {
                                   '':'home'
                                   }
                           });
  
                           var userList=new UserList();
                           var rou=new router();
                           rou.on('route:home',function(){
  
                                 userList.render();
  
                           });
                           Backbone.history.start();
                      &lt;/script&gt;
                  &lt;/body&gt;
              &lt;/html&gt;
  </code></pre>
  
  <p><strong>users.php</strong></p>
  
  <pre><code>                &lt;?php 
  
                      $request_method = strtolower($_SERVER['REQUEST_METHOD']);
  
  
  
                          $a=$_GET['id'];
                          mysql_connect("localhost", "root", "") or die("connection error");
                          mysql_select_db("dss") or die("db error");
                          $results=  mysql_query("select * from subscribers where EmailId='$a'");
  
                  ?&gt;
  </code></pre>