Skip to content

Instantly share code, notes, and snippets.

@andrewwatson
Created May 27, 2011 17:27
Show Gist options
  • Save andrewwatson/995732 to your computer and use it in GitHub Desktop.
Save andrewwatson/995732 to your computer and use it in GitHub Desktop.
A snippet to illustrate
Replace this code:
/* Create an Array of people to be called */
$people = array(
0 => "415-555-1234",
1 => "415-555-2345",
2 => "415-555-3456"
);
With this:
$sql = "SELECT phone_number, name FROM poll_takers";
$query = mysql_query($sql);
$people = array();
while($row = mysql_fetch_row($query, MYSQL_ASSOC)) {
$people[] = $row['phone_number'];
}
CREATE TABLE `poll_takers` (
id int auto_increment not null primary key,
phone_number varchar(20) not null default '',
name varchar(20) not null default ''
);
INSERT INTO `poll_takers` (phone_number, name) VALUES
('+14045551212', 'Bob'),
('+17705551212', 'Sam');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment