Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 多次运行阵列_Php_Sql - Fatal编程技术网

Php 多次运行阵列

Php 多次运行阵列,php,sql,Php,Sql,现在,我的脚本连接到一个api并发送一条短信,一次发送一个数字。我希望它从本地sql数据库中提取,然后对数据库中的每个数字重复响应 $data['post'] = array ( '_rnr_se' => $rnrse, 'phoneNumber' => '1234567890', 'text' => 'This is a test SMS!', 'id' => '' ); // Send th

现在,我的脚本连接到一个api并发送一条短信,一次发送一个数字。我希望它从本地sql数据库中提取,然后对数据库中的每个数字重复响应

$data['post'] = array (
    '_rnr_se'     => $rnrse,
    'phoneNumber' => '1234567890', 
    'text'        => 'This is a test SMS!',
    'id'          => '' 
);

// Send the SMS
$response = xcurl::fetch('api.phonegateway.com/', $data);

// Evaluate the response
$value = json_decode($response['data']);
如何执行此操作?


您必须设置一个本地数据库,从该数据库获取数字,然后对每个数字执行上述代码。这很快,因此这将遍历我数据库中的所有数字,并向每个数字发送响应?当您相应地调整代码时,是的。在while循环中,您编写的每一个代码都会像从database.thx返回结果一样频繁地执行,但我遇到了一个问题
mysql_connect("localhost", "mysql_user", "mysql_password") or
    die("Could not connect: " . mysql_error());
mysql_select_db("mydb");

$result = mysql_query("SELECT id, name FROM mytable");

while ($row = mysql_fetch_array($result)) {
    $data['post'] = array ( '_rnr_se' => $row['number'], 'phoneNumber' => $row['phone_number'], 'text' => $row['text'], 'id' => '' );

// Send the SMS $response = xcurl::fetch('api.phonegateway.com/', $data);

// Evaluate the response $value = json_decode($response['data']);` 
}