ajax php crud example

<?php
// Check if the form is submitted
$personName = $_POST['personName'];
$address = $_POST['address'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];
$message = $_POST['message'];
$tdate=new DateTime();
// form a sql query
$sql = "INSERT INTO tbquery (name, email, mobile,address, comment, postdate)
VALUES ('". $personName."',
'". $email ."',
'". $mobile ."',
'". $address ."',
'". $message ."',
'". $tdate->format('Y-m-d') ."'
)";
if (mysqli_query($conn, $sql)) {
echo "Your query posted successfully";
} else {
echo "Error: " . $sql . "" . mysqli_error($conn);
}

mysqli_close($conn);
 
?>

4
2
Dan Romik 125 points

                                    	$(document).on('click','#btn-add',function(e) {
		var data = $(&quot;#user_form&quot;).serialize();
		$.ajax({
			data: data,
			type: &quot;post&quot;,
			url: &quot;backend/save.php&quot;,
			success: function(dataResult){
					var dataResult = JSON.parse(dataResult);
					if(dataResult.statusCode==200){
						$('#addEmployeeModal').modal('hide');
						alert('Data added successfully !'); 
                        location.reload();						
					}
					else if(dataResult.statusCode==201){
					   alert(dataResult);
					}
			}
		});
	});
	$(document).on('click','.update',function(e) {
		var id=$(this).attr(&quot;data-id&quot;);
		var name=$(this).attr(&quot;data-name&quot;);
		var email=$(this).attr(&quot;data-email&quot;);
		var phone=$(this).attr(&quot;data-phone&quot;);
		var city=$(this).attr(&quot;data-city&quot;);
		$('#id_u').val(id);
		$('#name_u').val(name);
		$('#email_u').val(email);
		$('#phone_u').val(phone);
		$('#city_u').val(city);
	});
	
	$(document).on('click','#update',function(e) {
		var data = $(&quot;#update_form&quot;).serialize();
		$.ajax({
			data: data,
			type: &quot;post&quot;,
			url: &quot;backend/save.php&quot;,
			success: function(dataResult){
					var dataResult = JSON.parse(dataResult);
					if(dataResult.statusCode==200){
						$('#editEmployeeModal').modal('hide');
						alert('Data updated successfully !'); 
                        location.reload();						
					}
					else if(dataResult.statusCode==201){
					   alert(dataResult);
					}
			}
		});
	});
	$(document).on(&quot;click&quot;, &quot;.delete&quot;, function() { 
		var id=$(this).attr(&quot;data-id&quot;);
		$('#id_d').val(id);
		
	});
	$(document).on(&quot;click&quot;, &quot;#delete&quot;, function() { 
		$.ajax({
			url: &quot;backend/save.php&quot;,
			type: &quot;POST&quot;,
			cache: false,
			data:{
				type:3,
				id: $(&quot;#id_d&quot;).val()
			},
			success: function(dataResult){
					$('#deleteEmployeeModal').modal('hide');
					$(&quot;#&quot;+dataResult).remove();
			
			}
		});
	});
	$(document).on(&quot;click&quot;, &quot;#delete_multiple&quot;, function() {
		var user = [];
		$(&quot;.user_checkbox:checked&quot;).each(function() {
			user.push($(this).data('user-id'));
		});
		if(user.length &lt;=0) {
			alert(&quot;Please select records.&quot;); 
		} 
		else { 
			WRN_PROFILE_DELETE = &quot;Are you sure you want to delete &quot;+(user.length&gt;1?&quot;these&quot;:&quot;this&quot;)+&quot; row?&quot;;
			var checked = confirm(WRN_PROFILE_DELETE);
			if(checked == true) {
				var selected_values = user.join(&quot;,&quot;);
				console.log(selected_values);
				$.ajax({
					type: &quot;POST&quot;,
					url: &quot;backend/save.php&quot;,
					cache:false,
					data:{
						type: 4,						
						id : selected_values
					},
					success: function(response) {
						var ids = response.split(&quot;,&quot;);
						for (var i=0; i &lt; ids.length; i++ ) {	
							$(&quot;#&quot;+ids[i]).remove(); 
						}	
					} 
				}); 
			}  
		} 
	});
	$(document).ready(function(){
		$('[data-toggle=&quot;tooltip&quot;]').tooltip();
		var checkbox = $('table tbody input[type=&quot;checkbox&quot;]');
		$(&quot;#selectAll&quot;).click(function(){
			if(this.checked){
				checkbox.each(function(){
					this.checked = true;                        
				});
			} else{
				checkbox.each(function(){
					this.checked = false;                        
				});
			} 
		});
		checkbox.click(function(){
			if(!this.checked){
				$(&quot;#selectAll&quot;).prop(&quot;checked&quot;, false);
			}
		});
	});

4 (2 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
crud examples using php how to perform crud operation in php with image crud in php code php crud operation step by step crud class php php crud apps create crud with php php crud with ajax without jquery php crud javascript php crud with ajax jquery crud framework php php crud scripts simple crud php simple crud operations in php using mysql db crud tables in php crud php for beginners php mysql ajax crud tutorial crud query php mysql crud means in php crud operation using interface in php crud form php mysql ajax crud operation in php update crud operations php ajax crud con php php crud operation api example web service crud php ideas for crud operations in php get request using crud php view and crud operations in php mysql project register and crud operation php mysql source code Simple CRUD PHP using MYSQL function to crud database in php how create a crud using php Execute CRUD operations using PHP and MySQL crud application php api in php crud php and ajax crud php crud operation using mysql php crud from database php core crud full crud with php and show it in table in php crud php tuto crud php database ajax crud in php ajax crud php mysql inline crud php PHP oop CRUD programming examples php oop crud ajax php oop crud tutorial step by step simple crud in php with login simple php crud ajax operations with mysql php crud opration crud operations ideas in php php crud demo ajax crud operations in php and demo php crud in website crud php website simple php crud operations with microsoft sql server class crud php basic crud operation in php and mysql crud php mysql ajax how to make a crud in php ajax base crud in php create crud database using php language crud oop php crud php sql server products crud php crud operation in php source code php with crud operations php form with crud operations how to make website using basic php crud how to make crud web app using php crud application in php using oops CRUD EM PHP create CRUD calls to API php crud simple php mysql crud operation in php using jquery ajax php crud library php crud api example Complete CRUD Operation with Image Using PHP Mysql Database algorithm of crud operations in php php crud nedir code crud php simple crud project php mysql mvc and crud concept sample code in php crud operations using html php mysql php ajax crud master detail step by step CRUD using php, mysql and javascript php crud mysql tutorial ajax php crud operation ajax crud operations in php weblessons ajax crud operations in php framework crud php mysql simple php crud api simple crud operations php crud operations php crud operations php without ajax crud table php jquery ajax crud operations in php mvc php crud crud api php CRUD operation in PHP Source code download simple crud on phalcon php crud system with php php mysql crud example crud php html ajax use in crud operations php php crud functions crud php webbs how to create crud api in php php 7 crud example crud with php plain mysql crud php create a crud php basic php crud crud operations in php using ajax and jquery php crud ajax ajax crud php crud operation in php using hmvc crud operation in php using mvc ajax crud example in php php crud operation with ajax simple crud application in php mysql crud operation using class in php php crud with sql server core php crud operation with login crud systeem php php script crud structure crud php mysql what is php crud crud operation in php using session php code crud crud operation in php using oops CRUD model in pure php php crud website step by step crud in php php crud repository methods CRUD applications in mysql and php step by step CRUD application using mysql php and javascript ajax project of crud operation in file php sourcecodeste crud php meaning mysql crud operations in php crud php poo complete crud operation with php mysql database php crud opearation ajax code for crud operations in php simple example of a crud system using php and mysql php crud example companies Creating an automated crud operation in php classes Creating an automated crud operation in php oop Creating an automated crud operation in php ajax project of crud operation in php sourcecodeste php crud system php crud system programmingwitheva crud php demo PHP CRUD Tutorial with MySQL php crud oop example how learn php mysql crud operation crud operations in php template api crud operations in php PHP CRUD framework crud in php mysql with ajax crud php cli php crud operation using oops ajax crud opeation in php what is crud operation in php what is crud operations in php php ajax crud oops concept crud operation in php example CRUD php php crud operation code crud php example a step by step CRUD application using php and mysql core php crud operation with source code with demo core php crud operation with source code core php crud operation php mysql simple crud php simple crud example php simple crud php crud using ajax jquery php crud systeem php crud source code how to make simple crud in php and mysql simple crud operation in php using session php crud codeless crud operation in php download crud operation in ajax using php crud php oop crud php oop ajax create php crud application how to create a crud application in php crud php application crud script php CRUD in cli script php simple library management crud php create crud php mysql PHP CRUD shell simple php crud simple crud in php using mysql with view simple crud in php using mysql crud php simple example PHP CRUD image crud mvc php crud in php mvc crud application in php mysql crud function in php full form how to make crud in php and execute in my website php api crud crud function in php how to manipulate crud operation in php php &amp; mysql crud crud table in php crud database mysql php php crud app crud example in php jquery and ajax with code php complete crud with mysql php mvc crud operation php crud form crud operations from xml file php crud application in php with source code crud php mysql example full crud operation using php and mysql how to create crud in php javascript with php crud example what is php $crud php crud using oops framework php crud php crud using oop php crud using crud using oop in php php crud mysql php crud example crud php mysql crud operation with ajax and php crud operation ajax php crud with php mysql crud demo php easy crud php mysql make crud requests with PHP crud php feladatok php oop crud example php to build crud best way for crud php mysql how to make a crud app quickly in php php crud operation guru crud operation based on tables php script what is crud in php core php crud php automatic crud operation crud operations in php using mysql oops crud operation in php crud with php and mysql criar crud php crud php class with example php make crud crud in core php CRUD in php w3jar crud using ajax in php crud operation with login system in php CRUD EN PHP crud using php simple crud php source code image crud operation php and mysql crud php code source crud php code crud operation step by step in php how many crud in php AJAX PHP Crud Example php crud examples php crud tutorial php crud api crud operation in ajax php crud example in php ajax php crud php crud with mysql simple php crud operations with mysql simple crud using php php crud apu crud php tutorial crud application in php ajax crud operation in php simple crud operations in php using mysql crud system in php create button in php crud php 7 CRUD php mysql crud crud full form in php crud php source code Crud in php with mysql crud in php mysql lhttp://localhost/practice/CRUD/dashboard.php simple php crud code in php creating a crud oop crud operation in php localhostphpcrud/index.php crud project in php 2020 crud project in php php +mysql crud projects delete in crud php crud php mysqli crud of php php crud using mysql source code php database get data crud crud operation php php crud operation crud appl php crud operation using mysql and php Perform CRUD Operation with MySQL Database using PHP. Perform the required operation with single and multiple values. crud in php connect crud with schema php localhost\crud\form.php loccalhost\crud\form.php crud operation in php php mysql db table crud script crud programming php CRUD with PHP crud for update and delete in my sql by php PHP CRUD application crud operation tutorial In the header Section of the page show the Total number of Employee CRUD How to advanced CRUD operation from database in PHP and display in HTML list crud bostrap php php bootstrap5 mysql CRUD mariadb php crud tuto simple crud operation in php deplay simple php crud index with crud operations php index and process with crud operations php how to link index with php crud crud app in html download free simple mysql crud crud operations with proper filter and sorting using php mysql localhost/crud/index.php crud in php example delete crud php crud mysql php print command crud system php crud mysql php crud php php crud crud operations in php
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source