deleting
phpDOM parses xml documents and implements adding, deleting, modifying and checking nodes
php DOM is a tree-based parser, which requires you to view the xml document as a tree-like structure (introduction to xml documents). Take a look at the following simple xml document: Xiao Ming Male 11 Xiaohong Female 21 The following is to implement the operation of the nodes of the above class.xml document: php DOM implements traversal of nodes: load(“class.xml”); $stus =$xmldoc->getElementsByTagName(“stu”); //Access the value of the name node echo $stus->item(1)->getElementsByTagName(“name”)->item(0)->nodeValue; ?> Add node operations: load(“class.xml”); $root = $xmldoc->getElementsByTagName(“classes”)->item(0); $stu_node = $xmldoc->createElement(“stu”); //Add an attribute to the student $stu_node->setAttribute(“intro”,”This is a good student”); $name_node = $xmldoc->createElement(“name”); $name_node->nodeValue=”www.phpddt.com”; $stu_node->appendChild($name_node); $sex_node = $xmldoc->createElement(“sex”); $sex_node->nodeValue=”Male”; $stu_node->appendChild($sex_node); $age_node = $xmldoc->createElement(“age”); $age_node->nodeValue=23; $stu_node->appendChild($age_node); $root->appendChild($stu_node); $xmldoc->save(“new_class.xml”); ?> Delete node operation: load(“new_class.xml”); //If you want to delete it, you must find it $stus=$xmldoc->getElementsByTagName(“stu”); $stu1=$stus->item(0); $stu1->parentNode->removeChild($stu1); $xmldoc->save(“delete_class.xml”); ?> Update node operation: load(“new_class.xml”); //Update only when found $stus=$xmldoc->getElementsByTagName(“stu”); //Get the first student $stu1=$stus->item(0); //Change age to 100 $stu1_age = $stu1->getElementsByTagName(“age”)->item(0); $stu1_age->nodeValue = 100; $xmldoc->save(“new_class.xml”); ?>
thinkphp, you found a problem related to the failure of adding, deleting, and modifying associated operations.
php Write your review! Come on, watch it all Member login | User registration Recommended reading select Optimization principles of JOIN statements for tens of millions of tables –Optimization principles of mysqlJOIN statement–Optimization principles of mysqlJOIN statement–1. Small table drives large table (the first row of EXPLAIN is the driving table), WHE… [detailed] Crayon Shin-chan 2023-09-17 15:15:49 select Dynamic link library and shared memory: Dynamic link library and shared memory: We know that the dynamic link library (appears as .dll on Windows, and .so on Linux) uses a delayed loading mechanism, that is, the program is not called until it is called while it is running. will be loaded. A move… [detailed] Crayon Shin-chan 2023-09-17 15:15:00
JS sample code for adding, deleting, modifying and checking options of select control options_javascript skills-js tutorial
Javascript operation select is a common type of form. Here are several commonly used JS methods to dynamically operate select: The code is as follows: //Dynamicly create select function createSelect() { var mySelect = document.createElement (“select”); mySelect.id = “mySelect”; document.body.appendChild(mySelect); } The code is as follows: //Add option option function addOption() { //Find objects based on id, var obj=document.getElementById(‘mySelect’); //Add an optionobj.add(new Option(“text” ,”value”)); //This is only valid in IEobj.options.add(new Option(“text”,”value”)); //This is compatible with IE and firefox } The code is as follows: //Remove all options option function removeAll() { var obj=document.getElementById(‘mySelect’); obj.options.length=0; } The code is as follows: //Delete an option option function removeOne() { var obj=document.getElementById(‘mySelect’); //index, the serial number of the option to be deleted , here take the serial number of the currently selected optionvar index=obj.selectedIndex; obj.options.remove(index); } The code is as follows: //Get the text of optionvar obj=document.getElementById(‘mySelect’); var index=obj.selectedIndex; //Serial number, take the serial number of the currently selected optionvar val = obj.options[index].text; The code is as follows: //Modify option option var obj=document.getElementById(‘mySelect’); var index=obj.selectedIndex; //Serial number, take the serial number of the currently selected optionvar val = obj.options [index]=new Option(“new text”,”new value”);
Jquery’s operations of adding, deleting, modifying and checking select_jquery-js tutorial
There is no escape from the traditional four operations: add, delete, modify, and check. [Added]: The code is as follows: $(“#select_id”).append(“Text”); //Append an Option (drop-down item) to Select $(“#select_id”).prepend(“Please select”); //Insert an Option (first position) for Select [Delete]: The code is as follows: $(“#select_id option:last”).remove(); //Delete the Option with the largest index value in Select (the last one) $(“#select_id option[index=’0′]”).remove(); //Delete the Option (first) with index value 0 in Select $(“#select_id option[value=’3′]”).remove(); //Delete the Option with Value=’3′ in Select $(“#select_id option[text=’4′]”).remove(); //Delete the Option with Text=’4′ in Select $(“#select_id”).empty(); //Empty [Change](Set selected items): The code is as follows: $(“#select_id “).get(0).selectedIndex=1; //Set the item with Select index value 1 to select $(“#select_id “).val(4); //Set the Select value to 4 to select the item $(“#select_id option[text=’jQuery’]”).attr(“selected”, true); //Set the Text value of Select to the jQuery item selected [Check](Get the selected value): 1. Get the value of the selected item The code is as follows: $(“#select_id”).val(); //Get the value of the selected item $(“#select_id “).get(0).selectedIndex; //Get the index value of the selected item $(“#select_id”).find(“option:selected”).text(); //Get the text of the selected item $(“#select_id option:last”).attr(“index”); //Get the maximum index value of Select A code sample is attached. The code function is to change the…
Adding, deleting, modifying, and checking arrays of JavaScript study notes_javascript skills-js tutorial
The importance of arrays in programming languages is self-evident. Arrays in Javascript are also one of the most commonly used objects. Arrays are ordered collections of values. Due to weak types, arrays in Javascript are very flexible and powerful. Unlike Arrays in strongly typed high-level languages such as Java can only store elements of the same type or its subtypes. Javascript can store multiple types of elements in the same array, and the length can also be dynamically adjusted, and can be automatically adjusted as the data increases or decreases. Change the array length. Array is a common object in Javascript. It has some classic operations, such as adding, deleting, modifying and searching the array. This article mainly summarizes the relevant operation methods in this regard. Add array items First, let’s look at how to add array items to an array. Suppose there is an array: var arr = []; An array is declared above, but this array is an empty array [] with a length value of 0. Next we look at how to add array items to the array arr. The simplest way is to add array items to the array through index values: var arr = [];…
Tutorial on adding, deleting, modifying and querying data tables using SQL statements (phpMyAdmin usage tutorial)
In phpMyAdmin, we click sql to write complete sql statements to perform table operations, such as querying, adding, modifying, and deleting data tables, that is, We often talk about additions, deletions, modifications and checks. 1. SQL statements to add data tables Use sql statement to insert data, Here we need to use insert into In this way, the id in the table is 4 This data has been deleted. The above is the detailed content of the SQL statement to add, delete, modify and query data tables (phpMyAdmin usage tutorial). For more information, please pay attention to other related articles on 1024programmer.com!
Summary of examples of commonly used array array functions in PHP [assignment, splitting, merging, calculation, adding, deleting, querying, judging, sorting]
The examples in this article summarize the commonly used array array functions in PHP. Share it with everyone for your reference, the details are as follows: array_combine Function: Use the value of one array as the key name of the new array, and the value of the other array as the value of the new array Case: one [two] => two [three] => three ) */ array_chunk Function: split the number into multiple arrays “apple”,”b”=>”blue”,”c”,”d”,”e”); echo “”; print_r(array_chunk($input_array, 2)); print_r(array_chunk($input_array, 2,True)); echo ” “; /**result Array ( [0] => Array ( [0] => apple [1] => blue ) [1] => Array ( [0] => c [1] => d ) [2] => Array ( [0] => e ) ) Array ( [0] => Array ( [a] => apple [b] => blue ) [1] => Array ( [0] => c [1] => d ) [2] => Array ( [2] =>e ) ) */ array_count_values Function: Count the number of times a value appears in an array “apple”,”b”=>”blue”,”c”,”d”,”e”); echo “”; print_r(array_count_values($input_array)); echo ” “; /**result Array ( [apple] => 1 [blue] => 1 [c] => 1 [d] => 1 [e] => 1 ) */ array_diff Function: Remove the data in the second array…
Parsing Extjs and PHP data interaction (adding, deleting, checking and modifying)_PHP tutorial
The code is as follows: //The search is not done yet, the data is out, but it cannot be displayed Index.php file The code is as follows: <?phpheader(“Content:text/html;charset =utf-8”);$link = mysql_connect(“localhost”,”root”,”123456″)or die(‘error’.mysql_error());mysql_select_db(“stu”,$link );mysql_query(‘set names utf8’);$sql = “select count(*) num from men”;$num = mysql_query($sql);$count = mysql_fetch_array ($num);$start = $_POST[‘start’];$limit = $_POST[‘limit’];$sql2 = “SELECT * FROM men limit {$start}, {$limit}”;/*if (!$_POST){ $sql2 = “SELECT * FROM member”;} else { $sql2 = ” select * from member limit {$start},{$limit}”;}*/$data = array();$result = mysql_query($sql2); while(!!$info = mysql_fetch_array($result,MYSQL_ASSOC)){ $data[] = $info;}//$j = json_encode($data);$j = “{totalProperty:100,root:”.json_encode($data).”}”;echo $j;?> Add.php file As follows: The code is as follows: <?phpheader(“Content:text/html;charset=utf-8”);$link = mysql_connect(“localhost “,”root”,”123456″)or die(‘error’.mysql_error());mysql_select_db(“stu”,$link);mysql_query(‘set names utf8’); $name = $_POST[‘username’];$pwd = $_POST[‘password’];$time = $_POST[‘regTime’];$email = $_POST[’email ‘];/*$name = ‘aaaa’;$pwd = ‘aaaa’;$time = ‘2011-12-31’;$email = ‘aaaa ‘;*/$sql = “INSERT INTO men (username,password,regTime,email) VALUES (‘{$name}’,'{$pwd}’,'{$time}’,'{$email }’)”;//mysql_query($sql)if (mysql_query($sql)){ echo ‘ok’;}?> The Del.php file is as follows: The code is as follows: <?phpheader(“Content:text/html;charset=utf-8”) ;$link = mysql_connect(“localhost”,”root”,”123456″)or die(‘error’.mysql_error());mysql_select_db(“stu”,$link);mysql_query (‘set names utf8’);$id = $_POST[‘id’];$sql = “DELETE FROM men WHERE id={$id}”;if (mysql_query($sql )){ echo 1;} else { echo 0;}?> Database file men.sqlDatabase name: stuTable name: menYou can copy the following into a text document, then create a new stu database and import it. The code is as…
PHPer, suddenly tired of adding, deleting, modifying and checking every day, what else can I do?
How to adjust yourself? Reply content: 1. Have you left the JQ framework and can’t even write native JS for DOM operations? Have you left the DB class and can’t even write a simple query? Have you left the IDE and can’t even draw a table? Do you still know how to query multiple tables and subqueries? Do you only know that indexes are used to speed up queries? Are you still not able to write a slightly more complex OO class in PHP5? Will you be regular? How is your E-writing level? 2. Do you know selection sort, insertion sort, bubble sort, binary sort, Hill sort and can you write them out? Do you know how to traverse a binary tree? Do you know Hoffman? Do you know the picture? Do you know Runge-Kutta, iteration, interpolation, Younger, Newton’s descent method? Do you know the principle of ZIP compression? Are you so cute that you think that addition, subtraction, multiplication, division and loop judgment can complete the algorithm? Did you know that probability theory, calculus, and systems of linear equations are very, very basic in algorithms? 3. Have you never written a decent JS for your website? Are the effects…
Is it possible to achieve such a function using pure PHP without a framework? There are many pages with insert, delete, and modify functions. I only write one method of adding, deleting, and modifying, and other pages can also share this method.
Is it possible to achieve such a function using pure PHP without a framework? There are many pages with insert, delete, and modify functions. Just write one method of adding, deleting, and modifying, and other pages can also share this method. I used to write one method per page and insert it into the database accordingly. The boss requires all pages to write one type, and then other pages can also use this insertion method to insert into the database. How to do it? Can it be achieved? The inserted data table names and fields are all different, how to implement it? Reply to discussion (solution) Write a function or class, include the page you need to use, and just pass the parameters when calling. Just write a class. The boss said that it needs to be different, so there are parameters Write a class and pass the parameters in the method. Write a class and pass parameters in the method. How to submit ajax to the class method of this file? For example, the file is index.php, the class is add, and the method is insert() Write The parameters are passed in the class and then in the method.…