php - how to modified this code to display firstname,lastname and department only -


so samples of phonegap application few days ago "http://coenraets.org/blog/2011/10/sample-application-with-jquery-mobile-and-phonegap/" contain file.html

<!doctype html> <html> <head> <title>employee directory</title> <meta name="viewport" content="width=device-width,initial-scale=1"/> <link rel="stylesheet" href="css/jquery.mobile-1.0rc1.min.css" /> <link rel="stylesheet" href="css/styles.css" /> </head>  <body>  <div id="employeelistpage" data-role="page" >  <div data-role="header" data-position="fixed">     <h1>employee directory</h1> </div>  <div data-role="content">      <ul id="employeelist" data-role="listview" data-filter="true"></ul> </div>        </div>  <script src="js/jquery.js"></script> <script src="js/jquery.mobile-1.0rc1.min.js"></script> <script src="js/employeelist.js"></script> <script src="js/employeedetails.js"></script> <script src="js/reportlist.js"></script>  </body>  </html> 

file.js

enter code here  var serviceurl = "http://localhost/services/";  var employees;  $('#employeelistpage').bind('pageinit', function(event) { getemployeelist(); });  function getemployeelist() { $.getjson(serviceurl + 'getemployees.php', function(data) {     $('#employeelist li').remove();     employees = data.items;     $.each(employees, function(index, employee) {         $('#employeelist').append ('<li><a href="employeedetails.html?id=' + employee.id + '">' +                 '<h4>' + employee.lastname + '</h4>' +                 '<p>' + employee.title + '</p>' +                 '<span class="ui-li-count">'  + employee.reportcount + '</span></a></li>');     });     $('#employeelist').listview('refresh'); }); } 

file.php

<?php include 'config.php';  $sql = "select e.id, e.lastname, e.title, count(r.id) reportcount " .      "from employee e left join employee r on r.managerid = e.id " .     "group e.id order e.lastname";   try { $dbh = new pdo("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);   $dbh->setattribute(pdo::attr_errmode, pdo::errmode_exception); $stmt = $dbh->query($sql);   $employees = $stmt->fetchall(pdo::fetch_obj); $dbh = null; echo '{"items":'. json_encode($employees) .'}';  } catch(pdoexception $e) { echo '{"error":{"text":'. $e->getmessage() .'}}';  }   ?> 

and localhost database

"insert employee    (id,firstname,lastname,managerid,title,department,officephone,cellphone,email,city,picture) values (12,'steven','wells',4,'software architect','engineering','617-000-0012','781-000-0012','swells@fakemail.com','boston, ma','steven_wells.jpg')" 

i want ask should modify code display "lastname,department,and title" only, database in webbrowser.

$sql = "select e.id, e.lastname, e.title, e.department, count(r.id) reportcount " .  "from employee e left join employee r on r.managerid = e.id " . "group e.id order e.lastname"; 

and then

('<li><a href="employeedetails.html?id=' + employee.id + '">' +                 '<h4>' + employee.lastname + '</h4>' +                 '<p>' + employee.title + '</p>' +                 '<p>' + employee.department + '</p>' +                 '</li>'); 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -