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', '+60333');

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.

?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       +60333          I LOVE YOU
*/
}
?> 

How to writting multy query for it problem?..

Edited by gacoekchip.pokher

3
Contributors
11
Replies
12
Views
5 Years
Discussion Span
Last Post by pritaeas
0

I am sorry, I am confused by your question? What is "it problem"? What does it mean by "written query it"? You have already completed the task you are showing, what else do you need to do more?

0

it problem = problem multy query.
"written query it = how to query it?
I want to insert into outbox (phone_number,message)

/*
$phone_number=$phone   from contact table;
$string = "I LOVE YOU";
*/
0

It is my project sms gateway, i want to send message to group.

/* 
$massage = "I LOVE YOU";
$string = $massage;
*/

I am sorry because my english is bad.

Edited by gacoekchip.pokher

0

Does "multi query" mean you want to create multiple query at once? For example, "SELECT x FFROM y; UPDATE x SET k=aaa WHERE y=bbb;..." in one call?

0

@Taywin:
yes,

$string = "I LOVE YOU";
$phone_number=$phone;// value from contact table['phone']
$qr_outbox = "INSERT INTO outbox(phone_number,message ) 
VALUES ('$phone_number','$string')";
$rs_outbox = mysql_query($qr_outbox);

Edited by gacoekchip.pokher

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.