deleting
How does PHP+ajax realize uploading, deleting, modifying a single picture and background processing
This article will explain in detail how PHP+ajax realizes uploading, deleting, modifying a single picture and background processing. The editor thinks it is very practical, so I will share it with you as a reference. I hope You can gain something after reading this article. The details are as follows: Reason for update and revision: The ui display of the front interface is not good. The background processing logic is chaotic, and it is troublesome to process multiple pictures, so it is modified to upload/delete pictures through ajax. Effect: Before uploading:After uploading:After cancellation:The following is Updated Code: HTML Code: thumbnail the the the the the Upload picture undo image the Key points: The key points are all in the comments. Reference: JS+HTML implements a custom upload image button and displays images JS Code: //Upload pictures // Monitor input[type=file] $(“input[name=pic]”).on('change', function () { var e=$(this); var file=e[0].files[0]; var formData = new FormData(); formData.append(“pic”,file);//The name assigned to the picture here should correspond to the post value received in the following php $.ajax({ url: “{:url('upimg')}”, type: ‘POST’, Cache: false, //Upload files do not need to be cached data: formData, processData: false, // Tell jQuery not to process the sent data (specify whether the…
PHP student campus attendance management system, using MYSQL database, adding, deleting, modifying and checking
WebsiteIntroduction: Thisdynamic website usesMYSQLdatabase for voting information, message information, storage of user information, database link of the website The method isMYSQLI_CONNECTCompatibility is better, php7 and above can be used normally, this website is divided into There are two modules: students and teachers, in which students use to check their own attendance information, TeacherLaterTeacher canManage the main content of the websiteDelete and modify,Thiswebsite usesPHPSTUDYintegrated development environment, In addition, it is compatible withXAMPP, WAMP, APPSERV, etc.,we can provide softwaredownload and configuration tutorial. Development environment: Foreground of website:div+css+table Dynamic technology:PHP+MYSQL DevelopmentEnvironment: PHPSTUDY(CompatibleXAMPPXAMPP span>,WAMP,APPSERV) Page display: Main function: Foreground: user registration, user login, user message, voting Background: message management, vote deletion. Technical points: Add, delete, modify, check,$_COOKIE,SESSION insert add delete delete select query update update delete span>Update while, forloop display, ifconditional judgment, etc.. admin Default Account: Teacher Password: 123456 Note: The overall code of the website homework is a process-oriented native code that does not use object-oriented and frameworks. If you need it, please contact our customer service staff. Case address: https://www.zuoyewo.com/index/index/detail/id/43.html
Using PHP to connect to the database_an overall operation example of adding, deleting, modifying and checking user data
main page (main page) Code name Name Gender Ethnicity birthday Operation query($sql); $attr = $result->fetch_all(); foreach($attr as $v) { $sex = $v[2]? ‘male’:’female’; //ternary operator to determine gender $sql = “select Name from Nation where Code =’$v[3]'”; $result = $db->query($sql); $attr = $result->fetch_assoc(); echo ” {$v[0]} {$v[1]} {$sex} {$attr[‘Name’]} {$v[4]} delete Revise “; } ?> adding data Add(Add data page) Add data Code name: Name: gender: male female nationality: query($sql); $att = $r->fetch_all(); foreach($att as $v) { echo “{$v[1]}”; } ?> Birthday: AddChuLi page (add data processing page) query($sql); if ($result) { header(“location:main.php”); //php jump page method } else { echo “Failed to add!”; } DeleteChuLi page (delete data processing page) query($sql); if ($r) { header(“location:main.php”); } else { echo “Delete failed!”; } Update page (modify data page) Modify data query($sql1); $att1 = $r1->fetch_row(); ?> Code: <input type="hidden" name="code" value="” /> Name: <input type="text" name="name" value="” /> gender: <input type="radio" value="male" name="sex" / > male <input type="radio" value="female" name="sex" / > female nationality: query($sql); $att = $r->fetch_all(); foreach($att as $v) { if ($att1[3]==$v[0]) { echo “{$v[1]}”; } else { echo “{$v[1]}”; } } ?> Birthday: <input type="text" name="birthday" value="”/> ateChuLi page (modify data processing page) query($sql); if ($r) { header(“location:main.php”);…
listcode.cn is a code generator for adding, deleting, modifying and checking all platforms, java, python, php, nodejs can all be generated
what is listcode listcode.cn is essentially a cloud service website for code generation.Mainly provide Java, python, php, nodejs and other common languages and frameworks such as CRUD code generation services (that is, common additions, deletions and modifications), background code, front-end interface, js, etc., one-stop solution.Specific supported languages and technical frameworks: java,springmvc jpa mybatis php: laravel, thinkPhp5 python: flask, tonardo nodejs: vue, react, angular Look at a demo generated using listcode.cn What are the characteristics Support page turning: you can set the single page size. [Note 1 in Figure 1, Note 1 in Figure 3] Supports complex queries: combined queries with multiple conditions, each condition can be set with a prefix, such as greater than a certain value, like a certain value. [Note 1 in Figure 2, Note 3 in Figure 3] Perfect display and editing of foreign key tables: for tables referenced by foreign keys, a string type field is intelligently selected as a representative; a query window pops up when inputting, making the input more user-friendly. [Figure 1, 2, 3 mark 2, Figure 4, 5 mark 1] Specific type-specific display: date type, switch type, enumeration type, and will be continuously improved in the future [Figure 5] Support front-end and…
C# writes a set of the most complete MySQL helper class (including adding, deleting, modifying and checking)
C# writes a set of the most complete MySQL helper class (including adding, deleting, modifying and checking) Introduction:This helper class contains six main methods:ExecuteNonQuery, ExecuteScalar, ExecuteQuery, ExecuteQuery (generic), Insert, Update and Delete. Among them, ExecuteNonQuery is used to execute a SQL statement that does not return a result set;ExecuteScalar is used to execute a query and return the first column of the first row in the result set;ExecuteQuery is used to execute a query and Return the result set;ExecuteQuery (generic) is used to execute a query and map the result set to an object list;Insert is used to insert data into the database;Update is used to update the database Data;Delete is used to delete data in the database. 1. The following is a sample code of MySQL helper class based on C#, which can be used to connect to the database, execute SQL statements, read data and other operations: using System; using System.Collections .Generic; using System.Data ; using MySql.Data .MySqlClient; public class MySQLHelper { private string connectionString; public MySQLHelper(string connectionString) { this.connectionString = connectionString; } // does not The SQL statement that returns the result set public int ExecuteNonQuery( string sql, params MySqlParameter[] parameters) { using (MySqlConnection connection = new…
Hibernate+Maven+Struts2——Detailed steps for adding, deleting, checking and modifying CURD
First, let’s take a look at the rendering we want to achieve Next, the blogger’s code structure Go directly to the topic: 1. Create a database table 2. Create a project Create a Maven Project with Eclipse 3. Import hibernate-related rack packages into the project pom.xml 4.0.0 Maven_Hibenate01 Maven_Hibenate01 war 0.0.1-SNAPSHOT Maven_Hibenate01 Maven Webapp http://maven.apache.org -Dfile.encoding=UTF-8 junit junit 4.12 test javax.servlet javax.servlet-api 3.1.0 provided org.hibernate hibernate-core 5.2.10.Final org.apache.struts struts2-core 2.5.12 org.apache.struts struts2-convention-plugin 2.5.12 net.sf.json-lib json-lib 2.4 jdk15 mysql mysql-connector-java 5.1.18 Maven_Hibenate01 4.Configure hibernate.cfg.xml root 123 jdbc:mysql://localhost:3306/test?characterEncoding=utf8 com.mysql.jdbc.Driver 5.Create entity class User.java And the mapping file User.hbm.xml (the mapping file and the entity object must be in the same package) package com.yhl.entity; public class User { private int u_id;//number private String u_name;//User name private String u_sex;//sex public User() { } public User(int u_id) { this.u_id = u_id; } public User(String u_name, String u_sex) { super(); this.u_name = u_name; this.u_sex = u_sex; } public User(int u_id, String u_name, String u_sex) { this.u_id = u_id; this.u_name = u_name; this.u_sex = u_sex; } public int getU_id() { return u_id; } public void setU_id(int u_id) { this.u_id = u_id; } public String getU_name() { return u_name; } public void setU_name(String u_name) { this.u_name = u_name;…
CIPHP framework, how to use the database connection library class, examples of adding, deleting, modifying and querying database links
It is a long process to study the CI framework. I hope novices don’t worry, we will learn together. CI is called agile development, which has many advantages, such as database connection and database operation are very flexible, the following will show you the most basic code and some operations to deal with the database. Initialize the database class The following code will load and initialize the database class according to yours: $this->load->database(); Once loaded, you can use it anywhere like this: Note: If all your pages require the database class to be initialized, you can make it load automatically. Multi-result criteria query (object form) $query = $this->db->query(‘SELECT name, title, email FROM my_table’); foreach ($query->result() as $row) { echo $row->title; echo $row->name; echo $row->email; } echo ‘Total Results: ‘ . $query->num_rows(); The result() function above returns an array of objects. For example: $row->title Multi-result standard query (array format) $query = $this->db->query(‘SELECT name, title, email FROM my_table’); foreach ($query->result_array() as $row) { echo $row[‘title’]; echo $row[‘name’]; echo $row[’email’]; } The result_array() function above returns an indexed array. For example: $row[‘title’] Test query results If your query might not return results, we recommend that you test it first with the num_rows() function:…
Interacting with MySQL database through PDO extension to realize adding, deleting, modifying and querying and database transactions
Related learning recommendation: mysql tutorial Add, delete, modify and query through prepared statements Why use prepared statements We have briefly introduced the prepared statement in the previous tutorial. We can compare it with the view template. The so-called prepared statement is a predefined SQL statement template, and the specific parameter values are replaced by placeholders. : INSERT INTO REGISTRY (name, value) VALUES (?, ?) INSERT INTO REGISTRY (name, value) VALUES (:name, :value) Then bind the specific parameter value with the corresponding placeholder through a specific API method before actually executing the SQL statement and mapping. It’s as if the defined view template also replaces the variable with a specific placeholder, and then passes the variable value in to fill and render when it is actually rendered. Why take all this trouble? Wouldn’t it be nice to directly use the query method demonstrated earlier to add, delete, modify, and check? Uh, then let’s talk about the benefits of prepared statements, or why use prepared statements for database interaction. There are two advantages: First, use prepared statements to define in advance The SQL template will only be parsed once, but it can be executed multiple times by passing different parameter values, thereby…