Query and ajax are required in the while loop.

Source: Internet
Author: User
I would like to ask if your suggestion method is the same as mine? When I want to use artificial intelligence to collect information {code ...} however, if I need to write $ row [id] in the record to do other tasks, I have to put mysql_query in while so that I can know the $ row of each shard. [id] like this {code ...} so every... I would like to ask if your suggestion method is the same as mine?
When I want to use fake settings to collect information

While ($ row = mysql_fetch_array ($ SQL) {information display ...}

But I need to write $ row [id] in the information to do other things.
I have to put mysql_query in while so that I can know the $ row [id] of each shard.
Like This

while ($row=mysql_fetch_array($gettimeline)){$sql2 = mysql_query("SELECT * FROM `xxx`WHERE `id` = '".$row['id']."'");}

In this way, after each piece of information comes out
Won't He Repeat $ sql2 of each shard to check the Shard?
Is this method correct?
The same is true for ajax.
I want to delete an article to get the id of this article. I still have to put it in the while loop.

while ($row=mysql_fetch_array($gettimeline)){$sql2 = mysql_query("SELECT * FROM `xxx`WHERE `id` = '".$row['id']."'");《script》                        $("#remove_timeline_
  ").click(function(){                                $.ajax({                                    type: "POST",                                    url:"remove?to=
  ",                                    cache: false,                                    success: function(){                                                                            }                                });                            }                        });                        《script》                        }

In this way, each batch will have a re-built ajax and query. the more queries, the slower the query will be ....
What can we do?

Reply content:

I would like to ask if your suggestion method is the same as mine?
When I want to use fake settings to collect information

While ($ row = mysql_fetch_array ($ SQL) {information display ...}

But I need to write $ row [id] in the information to do other things.
I have to put mysql_query in while so that I can know the $ row [id] of each shard.
Like This

while ($row=mysql_fetch_array($gettimeline)){$sql2 = mysql_query("SELECT * FROM `xxx`WHERE `id` = '".$row['id']."'");}

In this way, after each piece of information comes out
Won't He Repeat $ sql2 of each shard to check the Shard?
Is this method correct?
The same is true for ajax.
I want to delete an article to get the id of this article. I still have to put it in the while loop.

while ($row=mysql_fetch_array($gettimeline)){$sql2 = mysql_query("SELECT * FROM `xxx`WHERE `id` = '".$row['id']."'");《script》                        $("#remove_timeline_
  ").click(function(){                                $.ajax({                                    type: "POST",                                    url:"remove?to=
  ",                                    cache: false,                                    success: function(){                                                                            }                                });                            }                        });                        《script》                        }

In this way, each batch will have a re-built ajax and query. the more queries, the slower the query will be ....
What can we do?

What does "circle" mean by "loop?

When the number of data entries increases, the number of requests increases. generally, such external IO duplicates will be considered for merging.
For example:

SELECT * FROM `xxx` WHERE id in (1,2,3,4,5)

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.