Jump to content

adamrifau

New Members
  • Posts

    4
  • Joined

  • Last visited

adamrifau's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thanks code was fixed by adding a form and clearing some old codes .
  2. Here is current steps i'm able to do following steps with the current code .. 1- connecting the device . 2 - pull the current data from attendance device . 3 dispay the data in current page (in this case index.php) pulled information 1- user id (from attendance device) 2- username 3- index number 4- check in status 5-date 6- time i'm trying to manully insert the data (via button) into mysql database . if user pressed the button which currently unable to process i've removed form fields and tables because i don't want to display data in current page.
  3. I'm Trying to INSERT Data into mysql which is generated from biomatric attendance device. Currently when the page loads all the data in the device will be displaying in a table. what i wanted to do is to save these data into mysql database. i have tried few codes none of these code works for me . please let me know how can i do this . <?php include 'db.php'; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script> <!-- <script type="text/javascript" src="load.js"></script> --> <link rel="stylesheet" href="style.css"> <title>Live Attendance</title> </head> <?php include("zklib/zklib.php"); $zk = new ZKLib("192.168.1.3", 4370); $ret = $zk->connect(); sleep(1); if ( $ret ): $zk->disableDevice(); sleep(1); ?> <body> <table border="1" cellpadding="5" cellspacing="2" style="float: left; margin-right: 10px;"> <tr> <th colspan="5">Data User</th> </tr> <tr> <th>UID</th> <th>ID</th> <th>Name</th> <th>Role</th> <th>Password</th> </tr> <?php try { //$zk->setUser(1, '1', 'Admin', '', LEVEL_ADMIN); $user = $zk->getUser(); sleep(1); while(list($uid, $userdata) = each($user)): if ($userdata[2] == LEVEL_ADMIN) $role = 'ADMIN'; elseif ($userdata[2] == LEVEL_USER) $role = 'USER'; else $role = 'Unknown'; ?> <tr> <td><?php echo $uid ?></td> <td><?php echo $userdata[0] ?></td> <td><?php echo $userdata[1] ?></td> <td><?php echo $role ?></td> <td><?php echo $userdata[3] ?> </td> </tr> <?php endwhile; } catch (Exception $e) { header("HTTP/1.0 404 Not Found"); header('HTTP', true, 500); // 500 internal server error } //$zk->clearAdmin(); if (isset($_POST['create_post'])) { $query = "INSERT INTO attendance(idx)"; $query .= "VALUES ($id)"; $submittodbquery = mysqli_query($con,$query); if (!$submittodbquery) { die("Failed up upload " . mysqli_error($con)); }else { echo "updated"; } } ?> </table> <button id="submit" type="submit" name="create_post" class="btn btn-danger">Submit New Post</button> <?php $name = $userdata[1]; $attendance = $zk->getAttendance(); sleep(1); while(list($idx, $attendancedata ) = each($attendance)): if ( $attendancedata[2] == 1 ) $status = 'Check Out'; else $status = 'Check In'; ?> <?php $idx ?> <?php $attendancedata[0] ?> <?php $attendancedata[1] ?> <?php $status ?> <?php date( "d-m-Y", strtotime( $attendancedata[3] ) ) ?> <?php date( "H:i:s", strtotime( $attendancedata[3] ) ) ?> <?php // custom code if (isset($_POST['submit'])) { $query = "INSERT INTO attendance(idx)"; $query .= "VALUES ($idx)"; $submittodbquery = mysqli_query($con,$query); if (!$submittodbquery) { die("Failed up upload " . mysqli_error($con)); }else { echo "updated"; } } ?> <?php endwhile ?> </table> <input type="submit" name="submit" value="Update Database"> <?php $zk->enableDevice(); sleep(1); $zk->disconnect(); endif ?> </body> </html> Thanks for reading my question ..
  4. how can i limit the data (display only last 10 )that display in this while loop $name = $userdata[1]; $attendance = $zk->getAttendance(); sleep(1); while(list($idx, $attendancedata ) = each($attendance)): if ( $attendancedata[2] == 1 ) $status = 'Check Out'; else $status = 'Check In'; ?> <tr> <td><?php echo $idx ?></td> <td><?php echo $attendancedata[0] ?></td> <td><?php echo $name ?></td> <td><?php echo $attendancedata[1] ?></td> <td><?php echo $status ?></td> <td><?php echo date( "d-m-Y", strtotime( $attendancedata[3] ) ) ?></td> <td><?php echo date( "H:i:s", strtotime( $attendancedata[3] ) ) ?></td> </tr>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.