0

Hi all,
Help me please.
i have two table: outbox and contact.
condition outbox table befor query/ insert.
CREATE TABLE outbox (
id int(11) NOT NULL,
phone_number varchar(30) NOT NULL,
message varchar(200) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Contact table:
CREATE TABLE contact (
id int(11) NOT NULL auto_increment,
name varchar(30) NOT NULL,
phone varchar(20) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

INSERT INTO contact VALUES (1, 'jana', '+60111');
INSERT INTO contact VALUES (2, 'jani', '+60222');
INSERT INTO contact VALUES (3, 'janu', '+602333');

I Want to insert a string to outbox table.
$string = "I LOVE YOU";

condition outbox table After Query/insert: Row of outbox table is:
CREATE TABLE outbox (
id int(11) NOT NULL,
phone_number varchar(30) NOT NULL,
message varchar(200) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO outbox VALUES (1, '+60111, 'I LOVE YOU');
INSERT INTO outbox VALUES (2, '+60222', 'I LOVE YOU');
INSERT INTO outbox VALUES (3, '+60333', 'I LOVE YOU');

How i write multy query mysql using php for it problem, thank you.

Edited by gacoekchip.pokher

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by gacoekchip.pokher
0

mysqli supports multiple statements. i don't think mysql does. however you can do multiple inserts with the values syntax. see the mysql online manual

0
<?php
$string = "I LOVE YOU";

$qr_contact = "SELECT * FROM contact";
$rs_contact = mysql_query($qr_contact);

while($data_contact = mysql_fetch_array($rs_contact))
{
  $id = $data_contact['id'];
  $name = $data_contact['name'];
  $phone = $data_contact['phone'];
  $xx = mysql_num_rows($rs_contact);

$phone_number=$phone;

$qr_outbox = "INSERT INTO outbox(id,phone_number,message ) VALUES ('','$phone_number','$string')";
$rs_outbox = mysql_query($qr_outbox); //how i written Query againt...?

/* how i written Query it?. 
After query Row of outbox table is:

id    phone_number       message                
1       +60111          I LOVE YOU 
2       +60222          I LOVE YOU
3       +602333         I LOVE YOU
*/

}

?> 
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.