tags:

views:

49

answers:

1

Hey i need help, right now my script connect to an api and send a sms, 1 number at a time, I want it to pull from a local sql db then repeat the response for each number in the db!

`$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']);`

A: 

Copy from the docs

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']);` 
}
DrColossos
that was fast, so this will go thru all the numbers in my db and send the response to each?
Aaron
When you adapt the code accoridngly, yes. Inside the while loop, every code you write will be as often executed as results are returned from the database.
DrColossos
thx again but i ran into a problem http://stackoverflow.com/questions/3130885/excute-an-array-with-while-statement
Aaron