PHPandAJAXMySQLDatabaseExample reference address: http://www.w3schools.com/PHP/php_ajax_database.asp
AJAX can be used for interactive communication with a database.
AJAX Database Example
In the AJAX example below we will demonstrate how a web page can fetch information from a MySQL database using AJAX technology.
Select a Name in the Box Below
Select a User: Peter Griffin in Lois Griffin in Joseph
.
PHP uasort () function
Definition and usage
The uasort () function uses the User-Defined comparison function to sort the array and maintain the index Association (no new key is assigned to the element ).
If the call succeeds, TRUE is returned. Otherwise, FALSE is returned.
This function is mainly used to sort the arrays that are very important to the unit order.
Syntax
Uasort (array, sorttype) parameter description
Array is required. Specifies the array to be sorted.
Required. User-defined fun
example is the same as example 1, but shows another method to create an array:
The instance code is as follows:
$ Ages ['Peter '] = "32 ";
$ Ages ['quagmire'] = "30 ";
$ Ages ['job'] = "34 ";
You can use the ID key in the script:
The instance code is as follows:
$ Ages ['Peter '] = "32 ";
$ Ages ['quagmire'] = "30 ";
$ Ages ['job'] = "34 ";
Echo "Peter is". $ ages ['Peter ']. "years old .";
?>
Output of the above script:Peter is 32 years old.
Multi-dimensional
";$ Ages ['job'] = "34 ";
You can use the ID key in the script:
The code is as follows:
$ Ages ['Peter '] = "32 ";$ Ages ['quagmire'] = "30 ";$ Ages ['job'] = "34 ";Echo "Peter is". $ ages ['Peter ']. "years old .";?>Output of the above script:Peter is 32 years old.
Multi-dimensional arrayIn a multi-dimensional array, each element in the main array is also an array. Each element in the sub-array can also be an array, and so on.
Example 1In this exam
The Uasort () function uses a user-defined comparison function to sort the array and keep the index associated (no new keys are assigned to the element).
Returns TRUE if successful, otherwise FALSE.
This function is primarily used to sort the associative arrays that are important for the cell order.
Grammar
Uasort (array,sorttype) parameter description
Array required. Specifies the array to sort.
function Required. User-defined functions.
The function must be designed to return 1, 0, or 1, and
Reference Address: http://www.w3schools.com/PHP/php_ajax_database.asp
AJAX can is used for interactive communication with a database.
AJAX Database Example
In the Ajax example below we'll demonstrate how a Web page can fetch information from a MySQL database using AJAX Techno Logy.
Select a Name in the Box Below
Select a user:peter Griffin Lois Griffin Joseph Swanson Glenn Quagmire
User info'll be
MySQL tutorial delete data SQL statement usage
The delete from statement is used to delete records from a database table.
Grammar
DELETE from table_name WHERE COLUMN_NAME = some_value
Note: SQL is not sensitive to case. Delete from is equivalent to delete from.
In order for PHP to execute the above statement, we must use the mysql_query (function). This function is used to send queries and commands to a SQL connection.
Example
Earlier, we created a table named "Person" in this tutorial. I
PHP updates to MySQL update
The UPDATE statement is used to modify the datasheet.Updating data in a databaseThe UPDATE statement is used to update the existing record table.Grammar
UPDATE table_name
SET column1=value, column2=value2,...
WHERE Some_column=some_value
Note: Note the WHERE clause in the updated syntax. The record or record specified in the WHERE clause should be updated.
If you ignore the WHERE clause, all records will be updated!To learn more about SQL, please vis
Label: The delete from command is used to delete data from a table.Delete from command format: Delete from table name where expressionFor example, delete the record numbered 1 in table MyClass:Mysql> Delete from MyClass where id=1;Please compare the table changes before and after deleting the data.
FirstName
LastName
Age
Peter
Griffin
35
Glenn
Quagmire
33
The fol
Update of MySQL in PHP
The UPDATE statement is used to modify data tables.Update database dataThe UPDATE statement is used to UPDATE an existing record table.Syntax
UPDATE table_nameSET column1=value, column2=value2,...WHERE some_column=some_value
Note: Pay attention to the update syntax of the WHERE clause. The records or records specified by the WHERE clause should be updated.If you ignore the WHERE clause, all records will be updated!For more information about SQL, see our SQL tutorial.To all
", "Lily"); B. In the following example, we manually allocate a digital ID key. $ Names [0] = "Peter"; $ names [1] = "Joe"; $ names [2] = "Lily"; these ID keys can be used in scripts:
2. join array:
Example 1 $ ages = array ("Peter" => 32, "Joe" => 30, "Lily" => 28); example 2 This example is the same as example 1, it is just another way to create an array. $ Ages ["Peter"] = "32"; $ ages ["Joe"] = "30"; $ ages ["Lily"] = "28 "; use the associated array in the script:
Output of the above sc
; 28); example 2 this example is the same as Example 1, it is just another way to create an array. $ Ages ["Peter"] = "32"; $ ages ["Joe"] = "30"; $ ages ["Lily"] = "28 "; use the associated array in the script:
3. Multi-dimensional array:
In this example, we have created a multidimensional array with the automatically assigned numeric ID key: $ families = array {"Griffin in" => array {"Peter", "Lois ", "Megan"}, "Quagmire" => array {"Glenn"}, "Brown
How MySQL updates database fields tutorial
Grammar
UPDATE table_name SET column_name = new_value WHERE column_name = some_value
Note: SQL is not sensitive to case. Update is equivalent to update.
In order for PHP to execute the above statement, we must use the mysql_query (function). This function is used to send queries and commands to a SQL connection.
Example
Earlier, we created a table named "Person" in this tutorial. It looks something like this:
FirstName LastName Age Peter
Tom's score is 96.45, 2 is named Joan, the result is 82.99, the number of 3 named Wang is 96.5.mysql> INSERT INTO MyClass values (1, ' Tom ', 96.45), (2, ' Joan ', 82.99), (2, ' Wang ', 96.59);Note: INSERT into can only insert a single record into the table at a time.5.5 Querying the data in a table1), query all rowsCommand: Select For example: View all data in table MyClassMysql> select * from MyClass;2), query the first few rows of dataFor example: View the first 2 rows of data in table MyCla
' s neighbors
Associative arrays
An associative array in which each ID key is associated with a value.
Using numeric arrays is not the best practice when storing data about a specific named value.
With associative arrays, we can use values as keys and assign values to them.
Example 1
In this example, we use an array to assign age to different people:
$ages = Array ("Peter" =>32, "quagmire" =>30, "Joe" =>34);
Example 2
This example is the same as Example 1, but it shows another way to create a
PHP MySQL Data Deletion Delete
The DELETE statement is used to record the deletion table.Delete data from a databaseThe deletion of the declaration is used to delete records from the database table.Grammar
DELETE from table_name WHERE some_column = some_value
Note: Note the syntax that is removed in the WHERE clause. The record or record specified in the WHERE clause should be deleted.
If you ignore the WHERE clause, all records will be deleted!To learn more about SQL, please
table name where expressionFor example, delete the record numbered 1 in table MyClass:Mysql> Delete from MyClass where id=1;Please compare the table changes before and after deleting the data.
FirstName
LastName
Age
Peter
Griffin
35
Glenn
Quagmire
33
The following is an example of PHP code to delete all Lastname= ' Griffin
precise and complex data.
5.6 Deleting data in a table
Command: Delete from table name where expression
For example: Delete a record in table MyClass that is numbered 1
Mysql> Delete from MyClass where id=1;
The following is a comparison of the tables before and after the data is deleted.
FirstName LastName Age
Peter Griffin
Glenn Quagmire 33
The following is an example of a PHP code that deletes all lastname= '
calls:
Back: "->"-Method call
Back to::-static method call
Return Nothing-function call
Args
Array
If you are in a function, list the function arguments. If you are referencing a file, list the names of the referenced files.
Grammar
Debug_backtrace () example
Copy Code code as follows:
function One ($str 1, $str 2)
{
Two ("Glenn", "quagmire");
}
function two ($str 1, $str 2)
{
Three ("Cleveland", "Brown");
}
is a comparison of the table before and after deleting the data.
FirstName
LastName
Age
Peter
Griffin
35
Glenn
Quagmire
33
The following is an example of PHP code to delete all Lastname= ' Griffin ' records in the "Persons" table:After this deletion, the table is like this:
FirstName
LastName
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.