我想要这样的东西:
$i = 1;
$y = 1;
while($i <= 10 and $y <= 5)
{
if($i==10)
{
echo 'I = '.$i.', Y = '.$y.'<br>';
$i = 1;
$y = $y+1;
}
else
{
echo 'I = '.$i.', Y = '.$y.'<br>';
$i = $i + 1;
}
}
哪个返回
I = 1, Y = 1
I = 2, Y = 1
....
I = 1, Y = 2
I = 2, Y = 2
....
I = 1, Y = 3
I = 2, Y = 3
等,等等,与 cURL 一起使用。但它不起作用。我究竟做错了什么?
$i = 1;
$y = 1;
while($y <= 9)
{
while($i==499)
{
if($connection = db_connect())
{
$post = array('something' => 'abc', 'value_of_y' => ''.$y.'', 'value_of_i' => ''.$i.'');
$str = curl_grab_page('http://localhost/send.php?true=1','','off',$post);
$str2 = mysql_real_escape_string($str);
$sql = "INSERT INTO abc (txt) VALUES ('$str2')";
$i = 1;
$y = $y+1;
}
else
{
echo 'Database connection error!';
}
}
while($i != 499)
{
if($connection = db_connect())
{
$post = array('something' => 'abc', 'value_of_y' => ''.$y.'', 'value_of_i' => ''.$i.'');
$str = curl_grab_page('http://localhost/send.php?true=1','','off',$post);
$str2 = mysql_real_escape_string($str);
$sql = "INSERT INTO abc (txt) VALUES ('$str2')";
$i = $i + 1;
}
else
{
echo 'Database connection error!';
}
}
}
但是页面一直在加载,没有任何反应。我必须使用“if($connection = db_connect()){”,但我认为这就是我的代码一直在搞砸的原因。请你看一下好吗?谢谢你。