Put DIV ID into a PHP Variable
<p>I am wanted to get the id's of all the divs on my page with the class <code>archive</code> and put them in a MySQL query to check and see if the ids are archived in the database.</p>

<p>So basically I am wondering how I can do this: <code>$div = $(this).attr('id');</code></p>

<p>Then I would throw it into the loop to check:</p>

<pre><code>$matches = mysql_query("SELECT * FROM content WHERE `div` = '$div'");
        while ($post = mysql_fetch_assoc($matches)) 
        {
            if (mysql_num_rows($matches) &gt; 0)
            { 
              //DO THIS
            }
        }
</code></pre>

<p>UPDATE</p>

<p>I have this code for the AJAX now:</p>

<pre><code>$('div.heriyah').each(function() { 
var curID = $(this).attr('id'); 
$.post("admin/btnCheck.php", { div : curID }, function(data) {
if (data == "yes") {
    $('#' + curID).html('&lt;div class=\"add\"&gt;&lt;div id=\"add_button_container\"&gt;&lt;div id=\"add_button\" class=\"edit_links\"&gt;  + Add Element&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=\"clear\"&gt;&lt;/div&gt;&lt;/div&gt;');
} else {
    $('#' + curID).html('&lt;div class=\"add\"&gt;&lt;div id=\"add_button_container\"&gt;&lt;div id=\"add_button\" class=\"edit_links\"&gt;  + Set As Editable Region&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=\"clear\"&gt;&lt;/div&gt;&lt;/div&gt;');
}
  });
});
</code></pre>

<p>And my PHP:</p>

<pre><code>$matches = mysql_query("SELECT * FROM content WHERE `div` = '".$_POST['div']."'");
 if (mysql_num_rows($matches) &gt; 0)
 { 
    echo "yes";
 } else {
    echo "no";
 }
</code></pre>

<p>What am I doing wrong?</p>
