Let's straight to the problem... I have this table, named 'phonenumber' :
+-------------+
| phonenumber |
+-------------+
| 555-123456 |
| 555-999999 |
| 555-888888 |
+-------------+
now, I want to send text message to those numbers by inserting message into this table, named 'outbox' :
+------+----------------+---------------------------------------------+
| ID | phonenumber | message |
+------+----------------+---------------------------------------------+
| ...... |
| 321 | 555-123456 | part 1 : lorem ipsum dolor sit amet |
| 322 | 555-999999 | part 1 : lorem ipsum dolor sit amet |
| 323 | 555-888888 | part 1 : lorem ipsum dolor sit amet |
+------+----------------+---------------------------------------------+
it's easy to do that. this SQL can do that job :
INSERT INTO outbox (phonenumber, message)
SELECT phonenumber, '$SMSMessage' as message
FROM phonenumber
WHERE purchasedate BETWEEN 2012-01-01 AND 2012-01-31;
the problem rise when text message more than 160 characters. it need to be splited and in this case, the second part of splited message must be stored on other table named 'outbox_multipart' and keep the ID number from 'outbox' so that the table will look like this :
+------+----------------+----------+----------------------------------+
| ID | phonenumber | outboxID | message |
+------+----------------+---------------------------------------------+
| ...... |
| 1025 | 555-123456 | 321 | part 2 : hello there! |
| 1026 | 555-999999 | 322 | part 2 : hello there! |
| 1027 | 555-888888 | 323 | part 2 : hello there! |
+------+----------------+---------------------------------------------+
please note : outbox.ID relates with outbox_multipart.outboxID.
and I have this PHP loop to insert the text message :
foreach ($CutMessage as $index => $SMSMessage)
{
if ($index == 0) {
**INSERT FIRST PART OF MESSAGE TO OUTBOX TABLE**
}else{
**INSERT SECOND / OTHER PART OF MESSAGE TO OUTBOX_MULTIPART TABLE**
}
}
how to correctly done this with PHP? thank you.