-1

以下情况的正确方法是什么

ive 100 个文件 db01.php db100.php

其中包括此 sql 语句

$sql = mysql_query("select user from level2 where id BETWEEN 1 AND 350");

my gol is update value ( BETWEEN 1 AND 350 )  

通过添加 +350 从 db01.php 到 db100.php

db02.php 语句将是

   $sql = mysql_query("select user from level2 where id BETWEEN 350 AND 700");

db03.php

        $sql = mysql_query("select user from level2 where id BETWEEN 700 AND 1050");

..继续到最后一个文件,最好的方法是什么!

4

1 回答 1

1

您可以使用 get 参数创建单个 PHP 文件,以指示文件的“编号”(在您的情况下,修改 BETWEEN 的开始和结束)。

尝试创建一个 PHP db.php 文件:

$interval = 350;
$num = (int) $_GET["num"];

// Generate start and end (for between)
$start = (int) $interval * ($num - 1);
$end = (int) $interval * $num;

// Hack for the first number (start should be 1, not 0)
if($start == 0) $start = 1;

// Generate sql with $start and $end)
$sql = mysql_query("select user from level2 where id BETWEEN " . $start . " AND " . $end);

然后这样称呼它:

http://www.yourside.com/db.php?num=1
http://www.yourside.com/db.php?num=2

ETC ...

于 2012-10-07T10:13:46.767 回答