php code send notification to all devices GCM
<p>I need a little help to send notification to all devices at once.
I know array need to be used for that but can't get the idea. A little hint will also work</p>

<pre><code>DB table design
id    gcm_regid   name  email   created_at 
</code></pre>

<p>Currently i have to fill out the form for all the devices and send notification one by one.</p>

<p>PHP code:</p>

<pre><code> &lt;html&gt;
   &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
    &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"&gt;    &lt;/script&gt;
    &lt;script type="text/javascript"&gt;
        $(document).ready(function(){

        });
        function sendPushNotification(id){
            var data = $('form#'+id).serialize();
            $('form#'+id).unbind('submit');
            $.ajax({
                url: "send_message.php",
                type: 'GET',
                data: data,
                beforeSend: function() {

                },
                success: function(data, textStatus, xhr) {
                      $('.txt_message').val("");
                },
                error: function(xhr, textStatus, errorThrown) {

                }
            });
            return false;
        }
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;?php
    include_once 'db_functions.php';
    $db = new DB_Functions();
    $users = $db-&gt;getAllUsers();
    if ($users != false)
        $no_of_users = mysql_num_rows($users);
    else
        $no_of_users = 0;
    ?&gt;
    &lt;div class="container"&gt;
        &lt;h1&gt;No of Devices Registered: &lt;?php echo $no_of_users; ?&gt;&lt;/h1&gt;
        &lt;hr/&gt;
        &lt;ul class="devices"&gt;
            &lt;?php
            if ($no_of_users &gt; 0) {
                ?&gt;
                &lt;?php
                while ($row = mysql_fetch_array($users)) {
                    ?&gt;
                    &lt;li&gt;
                        &lt;form id="&lt;?php echo $row["id"] ?&gt;" name="" method="post" onsubmit="return sendPushNotification('&lt;?php echo $row["id"] ?&gt;')"&gt;
                            &lt;label&gt;Name: &lt;/label&gt; &lt;span&gt;&lt;?php echo $row["name"] ?&gt;&lt;/span&gt;
                            &lt;div class="clear"&gt;&lt;/div&gt;
                            &lt;label&gt;Email:&lt;/label&gt; &lt;span&gt;&lt;?php echo $row["email"] ?&gt;&lt;/span&gt;
                            &lt;div class="clear"&gt;&lt;/div&gt;
                            &lt;div class="send_container"&gt;
                                &lt;textarea rows="3" name="message" cols="25" class="txt_message" placeholder="Type message here"&gt;&lt;/textarea&gt;
                                &lt;input type="hidden" name="regId" value="&lt;?php echo $row["gcm_regid"] ?&gt;"/&gt;
                                &lt;input type="submit" class="send_btn" value="Send" onclick=""/&gt;
                            &lt;/div&gt;
                        &lt;/form&gt;
                    &lt;/li&gt;
                &lt;?php }
            } else { ?&gt;
                &lt;li&gt;
                    No Users Registered Yet!
                &lt;/li&gt;
            &lt;?php } ?&gt;
        &lt;/ul&gt;
    &lt;/div&gt;
&lt;/body&gt;
</code></pre>

<p></p>

<p>send_message.php</p>

<pre><code>  &lt;?php
 if (isset($_GET["regId"]) &amp;&amp; isset($_GET["message"])) {
$regId = $_GET["regId"];
$message = $_GET["message"];

include_once './GCM.php';

$gcm = new GCM();

$registatoin_ids = array($regId);
$message = array("price" =&gt; $message);

$result = $gcm-&gt;send_notification($registatoin_ids, $message);

echo $result;
}
?&gt;
</code></pre>

<p>EDIT: Or can anyone tell me how do i use checkbox for select all "id"s?</p>
