<?php
//Mysql connection made here

mysql_connect ("dbserver", "dbuser", "dbpassword") or die(mysql_error());

mysql_select_db("dbname") or die(mysql_error());

//Useful functions comes here

function filter ($text) {
	return mysql_escape_string($text);

}

function sendmessage($number, $text) {

	$footer = "\nPowered by Spider.";  //Footer text
	$text = $text.$footer; 						//Remove this line to not add footer text.

	mysql_query("INSERT INTO `outbox`  (`id` ,`number` ,`processed_date` ,`insertdate` ,`text` ,`phone` ,`processed` ,`error` ,`dreport`) VALUES (NULL , '".filter($number)."', NOW( ) , '0000-00-00 00:00:00', '".filter($text)."', NULL , '0', '-1', '0');");

}

$tablename = "users";
$fieldname = "number";

//** WARNING ** This code won't work if the database of sms and database of this table are different. 

$data = mysql_query ("SELECT `".$fieldname."` FROM `".$tablename."`");

$message = "Hellooooooooooooooo :)";
while ($array = mysql_fetch_array ($data)) {

	sendmessage(trim($array[$fieldname]), $message);

}

?>