Jump to content

Arrays


bob_the _builder

Recommended Posts

Hi,

 

Im trying to grab a column of phone numbers from mysql table, send all the records across a hidden form field along with a message text area and reply field.

 

once submitted grab all the records from the phone number column and format it to:

 

$mobile = '12345,456788,566788,etc';

 

also grab the message post and reply post data

 

Basically so I can send a the same message to all the mobiles.

 

 

How could one acheive that?

 

 

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/46841-arrays/
Share on other sites

thats no explained well

 

I grab all the records from a field:

 

$sql = mysql_query('SELECT mobile FROM list');
while ($row = mysql_fetch_array($sql)) {
$mobile = $row['mobile'];
}

 

I want to get all the numbers from the mobile column into a variable like:

 

$mobile = '3245678,87978956,2321332,656546546,etc';

 

How can I go about that?

 

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/46841-arrays/#findComment-228303
Share on other sites

try

<?php
$res = mysql_query("SELECT phone FROM mytable") or die (mysql_error());
$phones = array();
while ($row = mysql_fetch_row($res)) {
    $phones[] = $row[0];
}
$phonelist = join (',', $phones);

#...

echo "<input type='hidden' name='phones' value='$phonelist' />";
?>

Link to comment
https://forums.phpfreaks.com/topic/46841-arrays/#findComment-228306
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.