diff --git a/lib/HistoricalRecord.dart b/lib/HistoricalRecord.dart index 8c41f84..20f18e5 100644 --- a/lib/HistoricalRecord.dart +++ b/lib/HistoricalRecord.dart @@ -29,20 +29,20 @@ class _HistoricalRecordState extends State { print('connect'); final conn = await MySQLConnection.createConnection( - //host: '203.64.84.154', - host: '10.0.2.2', + host: '203.64.84.154', + //host: '10.0.2.2', //127.0.0.1 10.0.2.2 - port: 3306, + port: 33061, userName: 'root', - //password: 'Topic@2024', - password: '0000', - //databaseName: 'care', //testdb - databaseName: 'testdb', + password: 'Topic@2024', + //password: '0000', + databaseName: 'care', //testdb + //databaseName: 'testdb', ); await conn.connect(); try { - var result = await conn.execute('SELECT * FROM users'); + var result = await conn.execute('SELECT HomeElderFall.*, HomeElder.heName FROM HomeElderFall JOIN HomeElder ON HomeElderFall.heId = HomeElder.heId;'); print('Result: ${result.length} rows found.'); if (result.rows.isEmpty) { @@ -51,14 +51,12 @@ class _HistoricalRecordState extends State { setState(() { _results = result.rows .map((row) => { - 'id': row.colAt(0), - 'name': row.colAt(1), - 'age': row.colAt(2), - 'gender': row.colAt(3), - 'phone': row.colAt(4), - 'email': row.colAt(5), - 'password': row.colAt(2) - }) + '長者ID': row.colAt(0),//去裝資料庫的行數 + '姓名': row.colAt(8), + '跌倒時間': row.colAt(1), + '跌倒原因': row.colAt(2), + '跌倒地點': row.colAt(7), + }) .toList(); }); } @@ -93,12 +91,12 @@ class _HistoricalRecordState extends State { itemCount: _results.length, itemBuilder: (context, index) { return ListTile( - title: Text(_results[index]['name']), + title: Text(_results[index]['姓名']), subtitle: Text( - 'age: ${_results[index]['age']}, ' - 'gender: ${_results[index]['gender']}, ' - 'phone: ${_results[index]['phone']}, ' - 'email: ${_results[index]['email']}', + '長者ID: ${_results[index]['長者ID']}\n, ' + '跌倒時間: ${_results[index]['跌倒時間']}\n, ' + '跌倒原因: ${_results[index]['跌倒原因']}\n, ' + '跌倒地點: ${_results[index]['跌倒地點']}\n', ), ); }, diff --git a/lib/PersonalInfo.dart b/lib/PersonalInfo.dart index c315467..067bea0 100644 --- a/lib/PersonalInfo.dart +++ b/lib/PersonalInfo.dart @@ -80,7 +80,7 @@ class _PersonalInfoState extends State { } void _saveChanges() async { - /*final conn = await MySQLConnection.createConnection( + final conn = await MySQLConnection.createConnection( host: '203.64.84.154', port: 33061, userName: 'root', @@ -88,7 +88,7 @@ class _PersonalInfoState extends State { databaseName: 'care', ); - await conn.connect();*/ + await conn.connect(); try { await conn.execute(