Hi All, help me please!.
How to create Query for my project problem.
Mysql table:
CREATE TABLE `outbox` (
`id` INT( 11 ) NOT NULL ,
`phone_number` VARCHAR( 20 ) NOT NULL ,
`text` VARCHAR( 160 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM ;
CREATE TABLE `contacts` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(25) NOT NULL,
`phone` varchar(20) NOT NULL,
`group_name` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
INSERT INTO `contacts` VALUES (1, 'jala', '+60111', 'friends');
INSERT INTO `contacts` VALUES (2, 'jali', '+60222', 'friends');
INSERT INTO `contacts` VALUES (3, 'jalu', '+60333', 'friends');
INSERT INTO `contacts` VALUES (4, 'kada', '+60444', 'members');
INSERT INTO `contacts` VALUES (5, 'kadi', '+60555', 'members');
INSERT INTO `contacts` VALUES (6, 'kadu', '+60666', 'members');
Form:
<html>
<body>
<h1>Form Send SMS Message</h1>
<form method="post" action="insert.php">
<table>
<tr><td>Send To</td><td>:</td><td>
<select name="group">
<option selected>Select Phone Group</option>
<option value="members">Members Group</option>
<option value="friends">Friends Group</option>
</select>
</td><tr>
</tr>
<tr><td>Message</td><td>:</td><td><textarea name="message" rows="10" cols="20"></textarea></td></tr>
</table>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
proses Form:
<?php
include ("koneksi.php");
$con = mysql_connect($servername,$username ,$password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("smsd");
$group=$_POST['group'];
$message=$_POST['message'];
$qr_contacts = "SELECT phone FROM contacts WHERE group_name = $group";
$rs_contacts = mysql_query($qr_contacts);
while($data = mysql_fetch_array($rs_contacts))
{
$id= $data['id'];
$phone= $data['phone'];
// I Want insert to outbox tabel (phone_number, text) VALUES ('$phone','$message')
// How to Create Query?
// Thank you.
}
?>