Php+mysql implementation of database random rearrangement instance _php technique

Source: Internet
Author: User

In this paper, the method of random rearrangement of php+mysql database is realized, and all the data in the table can be randomly read out once and then randomly saved to another table, thus the function of recording random is achieved.

The main implementation code is as follows:

Copy Code code as follows:
<?php
The database connection will not be written in this area.
$s = isset ($_get[' s ']) $_get[' s ']:0;
$e = isset ($_get[' e ']) $_get[' e ']:50;
$count = 85000;
if ($s < $count)
{
$sql = "SELECT * from table prefix _info where isget =0 order by id desc limit $s, $e";
$query = mysql_query ($sql);
while ($rs = Mysql_fetch_array ($query))
{
$id = $rs [' id '];
$sss = $rs [' SSS '];
$typeid = $rs [' typeid '];
$isget = $rs [' Isget '];
$sql = "INSERT into table prefix _info_bak (ID, table prefix, typeid,isget) VALUES (' $id ', ' $sss ', ' $typeid ', ' $isget ')";
mysql_query ($sql);
Echo $sql;
Exit
$SQLU = "Update table prefix _info set isget=1 where id =". $rs [' id '];
mysql_query ($SQLU);
}
Echo ' <meta http-equiv= "Refresh" content= "0;url=rand.php?s=". ($s +50). ' &AMP;E=50 "> Processing data, currently '. $s ... ' ... ';
}
Else
{
Echo ' completes all data processing <a href=rand.php> and then randomly sorts once </a> ';
}
?>

I hope this article will help you with your PHP program design.

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.