Home > Backend Development > PHP Tutorial > How to synchronize multiple data_PHP tutorial

How to synchronize multiple data_PHP tutorial

WBOY
Release: 2016-07-21 16:05:53
Original
1131 people have browsed it

Call out multiple pieces of data at once, then perform different processing "one by one" and "separately" on the same web page, and finally update or insert the database "at the same time". The update and insert data received for each piece of information are not the same! ============================
The main point of processing is _____ loop + array

1. From the database Call out data:
While db_query is looping, all the data that needs to be updated in the relevant fields are included in the array.
According to everyone's needs, these data can be presented in various forms such as text, checkbox, or hidden. Of course, checkbox is the most common type.
For example, mail processing web pages use checkbox extensively.
2. Modified data restore operation
The key point is count(array) + loop + db_update:
Loop based on the result of count, put db_update in, and let the loop complete the update and save operation of all data.
An example is as follows:
============================================== =======
####1.update.php: Use loop+array to retrieve data for update...


#Call database here
$query="select * from $userstable where.............................

#Enter the loop to retrieve data one by one
$i=0;
while ($i < $num):
.............................
$ id=mysql_result($result,$i,"id");
.............................
..... .....................
# Take out the fields that must be updated with the appropriate type to form an array.............
echo "< ;td align........................ 
echo "";
echo "";

$i++;
endwhile;


============================== =========================
####2.activate.php: After the data is updated, save it back through loop+array . ........

..... ) ; $i++) {
$name = $Cname[$i];
$id= $Cid[$i];

$query = "update $userstable set name='$ name ' where id='$id'";
.............

http://www.bkjia.com/PHPjc/315617.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315617.htmlTechArticleCall out multiple pieces of information at once, and then perform different processing "one by one" and "respectively" on the same web page. Finally, update or insert the database "at the same time". The update received for each piece of information...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template