Jump to content

Search the Community

Showing results for tags 'update'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi all, I am hopeless with Javascript etc but want to do updates, add, delete etc via a Bootstrap Modal. Everything works fine except for Update. No errors etc, just nothing happens. Here is the JS for the Update: $(document).on('click','.update',function(e) { var id=$(this).attr("data-id"); var name=$(this).attr("data-name"); var email=$(this).attr("data-email"); var phone=$(this).attr("data-phone"); var address=$(this).attr("data-address"); $('#id_u').val(id); $('#name_u').val(name); $('#email_u').val(email); $('#phone_u').val(phone); $('#address_u').val(address); }); $(document).on('click','#update',function(e) { var data = $("#update_form").serialize(); $.ajax({ data: data, type: "post", url: "includes/functions.php", success: function(dataResult){ var dataResult = JSON.parse(dataResult); if(dataResult.statusCode==200){ $('#editDriverModal').modal('hide'); alert('Data updated successfully !'); location.reload(); } else if(dataResult.statusCode==201){ alert(dataResult); } } }); }); Here is the php for the Update: if(count($_POST)>0){ if($_POST['type']==2){ $id=$_POST['id']; $name=mysqli_real_escape_string($con, $_POST['name']); $email=$_POST['email']; $phone=$_POST['phone']; $address=$_POST['address']; $query = "UPDATE `drivers` SET `name`='$name',`email`='$email',`phone`='$phone',`address`='$address' WHERE id=$id"; if (mysqli_query($con, $query)) { echo json_encode(array("statusCode"=>200)); } else { echo "Error: " . $query . "<br>" . mysqli_error($con); } mysqli_close($con); } } And finally the Bootstrap form: <!-- Edit Modal HTML --> <div id="editDriverModal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <form id="update_form"> <div class="modal-header"> <h4 class="modal-title">Edit User</h4> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> </div> <div class="modal-body"> <input type="hidden" id="id_u" name="id" class="form-control" required> <div class="form-group"> <label>Name</label> <input type="text" id="name_u" name="name" class="form-control" required> </div> <div class="form-group"> <label>Email</label> <input type="email" id="email_u" name="email" class="form-control" required> </div> <div class="form-group"> <label>PHONE</label> <input type="phone" id="phone_u" name="phone" class="form-control" required> </div> <div class="form-group"> <label>Address</label> <input type="city" id="address_u" name="address" class="form-control" required> </div> </div> <div class="modal-footer"> <input type="hidden" value="2" name="type"> <input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel"> <button type="button" class="btn btn-info" id="update">Update</button> </div> </form> </div> </div> </div> Data displays fine inside the Modal so it is communicating with the Database. But just when I click on Update nothing happens. Any help or guidance would really be appreciated. Thanks in advance...
×
×
  • 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.