Pass multiple values to jQuery
<p>I built a for each loop that pulls back several rows from the database. Each row it pulls has a link, and a hidden input box with a value of posting_id. This link will work similar to a like button on facebook in a way. The hidden input box just stores the posting_id. When you click the "like" link, it sends over the posting_id to a jQuery page and pings back a page called community to tell it the user has "liked" the post.</p>

<p><strong>Here's the problem</strong></p>

<p>I'm pulling several rows, and it seems that only the top row being pulled is actually sending the data to the jQuery page when you click the "like" button. If I click on any other "like" button other than the top one it will not work at all.</p>

<p><strong>Jquery Page</strong></p>

<pre><code>$('.bump_link').click(function(){ 
    var posting_id = $('.posting_id').val();    
    $.post("community.php", {
        posting_id: posting_id
    });
    alert(posting_id);
    $(this).toggleClass("bumped"); 
});
</code></pre>

<p><strong>Foreach Loop</strong></p>

<pre><code>foreach ($result as $value) {
    $group_postings .= '
    &lt;input type="text" class="posting_id" value="'.$value['posting_id'].'"&gt; 
    &lt;div id="bump_icon" class="bump_link"&gt;&lt;/div&gt;
    &lt;span id="counter"&gt;&lt;/span&gt;
    ';
}
</code></pre>

<p>I hope I've made the issue clear, it was and is difficult to explain.</p>
