-3

数日前に「 http://coenraets.org/blog/2011/10/sample-application-with-jquery-mobile-and-phonegap/ 」から phonegap アプリケーションのこのサンプルを取得しました。これには 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 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

"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','swells@fakemail.com','Boston, MA','steven_wells.jpg')"

のデータベースからコードをdisplay単にに変更するにはどうすればよいかを尋ねたいです。"lastname,department,and title" onlywebbrowser

4

1 に答える 1

0
$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 by e.id order by e.lastName";

その後

('<li><a href="employeedetails.html?id=' + employee.id + '">' +
                '<h4>' + employee.lastName + '</h4>' +
                '<p>' + employee.title + '</p>' +
                '<p>' + employee.department + '</p>' +
                '</li>');
于 2013-05-03T10:59:05.090 に答える