nice work please add option…
nice work
please add option to edit or remove item
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> <a class="navbar-brand" href="https://sourcecodester.com">Sourcecodester</a> </div> </nav> <div class="col-md-3"></div> <div class="col-md-6 well"> <h3 class="text-primary">PHP - Insert Data To JSON File</h3> <hr style="border-top:1px dotted #ccc;"/> <div class="col-md-4"> <form method="POST" action="insert.php"> <div class="form-group"> <label>Firstname</label> <input type="text" class="form-control" name="firstname" required="required"/> </div> <div class="form-group"> <label>Lastname</label> <input type="text" class="form-control" name="lastname" required="required"/> </div> <div class="form-group"> <label>Address</label> <input type="text" class="form-control" name="address" required="required"/> </div> <center><button class="btn btn-primary" name="insert">Insert</button></center> </form> </div> <div class="col-md-8"> <table class="table table-bordered table-striped"> <thead class="alert-info"> <th>Firstname</th> <th>Lastname</th> <th>Address</th> </thead> <tbody> <?php foreach($data as $fetch){ ?> <tr> <td><?php echo $fetch->firstname?></td> <td><?php echo $fetch->lastname?></td> <td><?php echo $fetch->address?></td> </tr> <?php } ?> </tbody> </table> </div> </div> </body> </html>
[ { "firstname": "John", "lastname": "Smith", "address": "New York" }, { "firstname": "Claire", "lastname": "Temple", "address": "Racoon City" } ]
<?php 'firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'address' => $_POST['address'] ); $json[] = $array; } ?>