-3
그래서 내가 얻을 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
를 포함하는 " http://coenraets.org/blog/2011/10/sample-application-with-jquery-mobile-and-phonegap/" 에서 몇 일 전 폰갭 응용 프로그램의 샘플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 by e.id order by 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() .'}}';
}
?>
은이는 내 localhost database
내가 webbrowser
내 데이터베이스에서, display
단순히 "lastname,department,and title" only
에 내 코드를 수정해야 할 일 물어보고 싶은
"INSERT INTO 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','[email protected]','Boston, MA','steven_wells.jpg')"
.
는 actualy 난 (e.lastName이 e.title, e.department는, 계산, "$의 SQL은 ="e.id 선택 r.id를 포함의 설명을 이해 해달라고) reportCount ". "종업원 e에서 왼쪽 r.managerId = e.id " "e.lastName에 의해 e.id 순서로 그룹에 가입; "" 직원 e에서 "e.id", "기능 및"은 무엇입니까? e.id, e.lastName, e.title, e.department, count (r.id) reportCount " " r.managerId = e.id " "e.lastName by e.id order by "그룹을 참조 하시겠습니까? – hardsolidman
현재 제공되는 $ sql = line을 file.php로 바꾸면됩니다. 부서도 지정합니다. 그런 다음 file.js의 코드 부분을 다음 비트로 바꿉니다. – parnas