How to Delete record using PHP Ajax
index.php
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | <!DOCTYPE html> <html> <head> <title></title> </head> <body> <?php $connection = mysqli_connect( "localhost" , "root" , "" , "db_2018" ) or die (mysqli_error()); $ReadSql = "SELECT * FROM `crud`" ; $res = mysqli_query( $connection , $ReadSql ); ?> <table> <tr> <th>name</th> <th>Last Name</th> <th>email id</th> <th>gender</th> <th>age</th> <th>Action</th> </tr> <?php while ( $fetch = mysqli_fetch_array( $res )) { extract( $fetch ); ?> <tr> <td><?php echo $fetch [ 'first_name' ]; ?></td> <td><?php echo $fetch [ 'last_name' ]; ?></td> <td><?php echo $fetch [ 'email_id' ]; ?></td> <td><?php echo $fetch [ 'gender' ]; ?></td> <td><?php echo $fetch [ 'age' ]; ?></td> <!-- <input type= "hidden" name= "" id= "v" value= "<?php //echo $fetch['id']; ?> " > --> <td><a href= "javascript:;" class = 'delete' id= '<?php echo $fetch[' id ']; ?>' > Delete </a></td> </tr> <?php } ?> </table> <script type= "text/javascript" src= "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" ></script> <script type= "text/javascript" > $(document).ready( function (){ $( ".delete" ).click( function (){ var id= $(this).attr( "id" ); $.get( "delete.php" ,{id:id}, function (data){ alert( 'deleted successfully' ); }); }); }); </script> </body> </html> |
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <?php $connection = mysqli_connect("localhost","root","","db_2018") or die(mysqli_error()); $ReadSql = "SELECT * FROM `crud`"; $res = mysqli_query($connection, $ReadSql); ?> <table> <tr> <th>name</th> <th>Last Name</th> <th>email id</th> <th>gender</th> <th>age</th> <th>Action</th> </tr> <?php while($fetch = mysqli_fetch_array($res)) { extract($fetch); ?> <tr> <td><?php echo $fetch['first_name']; ?></td> <td><?php echo $fetch['last_name']; ?></td> <td><?php echo $fetch['email_id']; ?></td> <td><?php echo $fetch['gender']; ?></td> <td><?php echo $fetch['age']; ?></td> <!-- <input type="hidden" name="" id="v" value="<?php //echo $fetch['id']; ?> "> --> <td><a href="javascript:;" class='delete' id='<?php echo $fetch['id']; ?>'>Delete</a></td> </tr> <?php } ?> </table> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".delete").click(function (){ var id= $(this).attr("id"); $.get("delete.php",{id:id},function(data){ alert('deleted successfully'); }); }); }); </script> </body> </html>
delete.php
01 02 03 04 05 06 07 08 09 10 11 | <?php $con = mysqli_connect( "localhost" , "root" , "" , "db_2018" ); $id = $_GET [ 'id' ]; $del_query =mysqli_query( $con , "delete from crud where id='$id'" ) or die (mysqli_error( $con )); ?> |
<?php $con = mysqli_connect("localhost","root","","db_2018"); $id=$_GET['id']; $del_query=mysqli_query($con,"delete from crud where id='$id'") or die(mysqli_error($con)); ?>
Your blog is so nice, and the article is very good it helps to so many people.
ReplyDeletePHP Training in Hyderabad
Want to get ranked your business on the top? Contact Shahni Digital Media, one of the fastest growing Digital Marketing Company in India. We provide web development solution, orm, ppc, smm, sem etc.
ReplyDeleteDigital Marketing Company Bhopal
Website Designing Company Bhopal
SEO Company in Bhopal
ORM Company India
Thanks for sharing such an informative blog.
ReplyDeletePHP Classes in Bangalore
Web Designing Training in Bangalore
UI/UX Design Courses in Bangalore
I need to to thank you for this excellent read!! I absolutely loved every bit of it. I have you saved as a favorite to look at new things you post…
ReplyDeleteUI Development Training in Bangalore
Reactjs Training in Bangalore
I undoubtedly welcome the way wherein you continue posting such shocking and huge articles and continue empowering your blog with most recent bearing. Keep up this goliath work. Keep framing. Dedicated hosting reviews
ReplyDeleteThank you for sharing this post.
ReplyDeleteSAP Training in Chennai
Hardware and Networking Training in Chennai
Cloud Computing Training in Chennai
Pearson Vue Exam Center in Chennai
Oracle Training in Chennai
.Net Training in Chennai
Java Training in Chennai
Software Testing Training in Chennai
AWS Training in Chennai
CCNA Training in Chennai
Great Article ,I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
ReplyDeleteDevOps Training in Chennai
DevOps Online Training in Chennai
DevOps Training in Bangalore
DevOps Training in Hyderabad
DevOps Training in Coimbatore
DevOps Training
DevOps Online Training
Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign.thanks lot!!
ReplyDeleteJava training in Chennai
Java Online training in Chennai
Java Course in Chennai
Best JAVA Training Institutes in Chennai
Java training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Training
Java Online Training
thank you for the information. it is useful and informative
ReplyDeleteangular js training in chennai
angular training in chennai
angular js online training in chennai
angular js training in bangalore
angular js training in hyderabad
angular js training in coimbatore
angular js training
angular js online training
ReplyDeleteThanks for your interesting ideas.the information's in this blog is very much useful for me to improve my knowledge.
AWS Course in Chennai
AWS Course in Bangalore
AWS Course in Hyderabad
AWS Course in Coimbatore
AWS Course
AWS Certification Course
AWS Certification Training
AWS Online Training
AWS Training
I need to to thank you for this excellent read!! I absolutely loved every bit of it. I have you saved as a favorite to look at new things you post…
ReplyDeleteacte reviews
acte velachery reviews
acte tambaram reviews
acte anna nagar reviews
acte porur reviews
acte omr reviews
acte chennai reviews
acte student reviews
I need to to thank you for your time due to this fantastic read!! I definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.
ReplyDeletepython training in bangalore
python training in hyderabad
python online training
python training
python flask training
python flask online training
python training in coimbatore
python training in chennai
python course in chennai
python online training in chennai
JavaScript will remain a very popular language for years to come. it would be suicide to your career as a web developer not to know it. It's foreseeable that JavaScript will not only conserve but extend its hold of the overall software industry during the coming years.keep up!!
ReplyDeleteAndroid Training in Chennai
Android Online Training in Chennai
Android Training in Bangalore
Android Training in Hyderabad
Android Training in Coimbatore
Android Training
Android Online Training
I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
ReplyDelete| Certification | Cyber Security Online Training Course | Ethical Hacking Training Course in Chennai | Certification | Ethical Hacking Online Training Course | CCNA Training Course in Chennai | Certification | CCNA Online Training Course | RPA Robotic Process Automation Training Course in Chennai | Certification | RPA Training Course Chennai | SEO Training in Chennai | Certification | SEO Online Training Course
Si Contact Form Plugin using for captcha to setup contact form in get it proper way it make properly
ReplyDeleteWoocommerce Floating Cart setup in woocommerce side cart in your ecommerce website
ReplyDeletefast secure contact form for setup contact form with captcha and secure in your wordpress site
ReplyDeleteCalculated Fields Form WordPress Plugin In Calculate Field to each other we can use wordpress plugin for calculation. let We explain you how to make Calculation Field in wordpress.
ReplyDeleteCalculated Fields Form WordPress Plugin In Calculate Field to each other we can use wordpress plugin for calculation. let We explain you how to make Calculation Field in wordpress.
ReplyDeleteThank you for discussing this very useful article. I heard something new from you. Keep blogging. php training in jalandhar
ReplyDeleteThis comment has been removed by the author.
ReplyDeletevisit our website
ReplyDeleteThanks for sharing such types of articles on your website. I have read the complete article that you have explained properly. Thanks a lot for this article. For any kind of website development in the PHP Language,
ReplyDeletevisit our website
Thanks for providing awesome lecture about PHP. I hope you will keep it up.
ReplyDeleteIt is nice post and I found some interesting information on this blog, keep it up. Thanks for sharing. . .
ReplyDeleteHire PHP framework in India
Thanks for sharing..
ReplyDeleteAWS solution Architect job available in Chennai