The novice solves the problem of the contrast between the result set and the array.

Source: Internet
Author: User
1 tables

----------------------------
| ID | name | baodao| Time |
| 2 | ted | Xiao Ming | 22:10|
| 1 | Zhang Sanming | Small three | 17:10|
------------------------------

First, I'll collect the information.
$url = "http://www.abc.com";
$duUrl =file_get_contents ("$url");
$name = "/bs\[.*\]\s*\=\s*new\s*book\ (\ ' [0-9]*\ ' \,\ ' (. *?) \ ' \,\ ' [0-9]*\ ' \,\ '. *\ ' \,\ '. *\ ' \,\ ' [0-9]*\ ' \,\ ' (. *?) \ ' \,\ ' [0-9]*\ ' \,\ '. *\ ' \,\ ' [0-9]*\ ' \,\ '. *\ ' \,\ ' (. *?) \ '/iu ';
Preg_match_all ($name, $DUURL, $xiaoname);
$a = $xiaoname [1];
$b = $xiaoname [2];
$c = $xiaoname [3]; These 3 are the values collected back.

Ask. If the first one comes back, there are nnnn behind. I
$a = Ted;
$b = 23:13;
$c = Rongrong;

Solution, when I get the value of 1 $a, I want to compare it to the value in the field Baodao of the database.
Modify the Time field if one is available and skip if it is not.

That's probably the way it is. Beginners are hard to understand. PHP prawns, pointing fingers.


Reply to discussion (solution)

Added,

When the value of $a is Ted, take this Ted as a condition for searching the database. If there is $c = Rong Rong $b 2 values modified.
If not, skip.

I will not be able to find the result set.

$mysqli =new mysqli ("localhost", "root", "AA", "AA");
$mysqli->query ("Set names UTF8");
if (Mysqli_connect_errno ()) {
echo "Error:". Mysqli_connect_error ();
Exit
}

There's another idea.

The collection is an array.
If you can declare all the values in the field name back to the array,
Then you can use In_array to compare. If there is, insert, if not ...
But the name is declared back to the array, how is this done?

$sql = "Update Biao set baodao= ' $b ', time= ' $c ' where name= ' $a '";
$mysqli->query ($sql);

But first you have to solve a problem: what to do when the same name occurs
The Name column has two Ted how to do it?

$sql = "Update Biao set baodao= ' $b ', time= ' $c ' where name= ' $a '";
$mysqli->query ($sql);

But first you have to solve a problem: what to do when the same name occurs
The Name column has two Ted how to do it?

Ted will not appear more than 2, only 0 or 1 times.

Well, that's not the problem.

Do you mean if the database has this field to update without inserting it?

 
  Query ("SELECT * from Biao where Baodao = ' $a ')") {//Results update $mysqli->query ("Update Biao set baodao= ' $b ', time= ' $c ' where n Ame= ' $a ');} else{//Insert $mysqli->query ("INSERT into Biao (' $a ', ' B ', ' C ')") without result;}? >

 
  Query ("SELECT * from Biao where Baodao = ' $a ')") {//Results update $mysqli->query ("Update Biao set baodao= ' $b ', time= ' $c ' where n Ame= ' $a ');} else{//Insert $mysqli->query ("INSERT into Biao (' $a ', ' $b ', ' $c ')") without result;}? >

 
  Query ("SELECT * from Biao where Baodao = ' $a ')") {//Results update $mysqli->query ("Update Biao set baodao= ' $b ', time= ' $c ' where n Ame= ' $a ');} else{//Insert $mysqli->query ("INSERT into Biao (' $a ', ' $b ', ' $c ')") without result;}? >


No, just keep jumping and jumping. Jump to have so far, Ted these data when manually added, baodao| Time these 2 fields are used for remediation and routine maintenance.
  • Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.