请帮帮我。我想从联系人表插入到发件箱表。
接触:
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');
发件箱:
CREATE TABLE `outbox`
(`id` int(11) NOT NULL,
`phone_number` varchar(20) NOT NULL,
`text` varchar(160) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;}
我想插入发件箱表。
插入.php
$sql =mysql_query("SELECT phone
FROM contacts
WHERE group_name = 'member'");
while($data = mysql_fetch_array($sql))
{ $id= $data['id']; $phone= $data['phone'];(phone_number, text) VALUES('$phone','I LOVE YOU') }?>