function displayCenter() { include "center.php"; $obj = new center(); if (!$obj->view_center()) { echo '{"result": 0, "mesage": "Failed to fetch"}'; return; } else { echo '{"result":1,"center":['; $row = $obj->fetch(); while ($row) { echo json_encode($row); $row = $obj->fetch(); if ($row) { echo ","; } } echo "]}"; } }
<?php /** * * @var * */ if (isset($_REQUEST['id'])) { include "center.php"; //create object of centers $obj = new center(); $row = $obj->view_center(); $result = $obj->view_center($id); if (!$result) { echo '{"result": 0, "message": "Error displaying centers"}'; return; } else { echo '{"result": 1, "message": "Displaying centers"}'; return; } }
<?php include 'center_class.php'; include 'user_class.php'; $chelmsford = new center(); $chelmsford->name = 'example_php'; $chelmsford->purchaser = '*****@*****.**'; $chelmsford->save(); $me = new user(); $me->center = $chelmsford->name; $me->username = '******'; $me->email = '*****@*****.**'; $me->accountType = 1; $me->voiceDialect = 2; $me->save();