[Solved] Displaying individual post ids of queried columns in a php while loop with jquery [closed]


It is because you are using id and id works for a single element. For more then one occurrence try class instead, like:

PHP:

for($results as $result)
{
    echo '<li class="link">'.$result.'</li>';
}

JS:

$('.link').click(function(){
    var post = $(this).html();    // here you can use val(), id() also depends on your code
    alert(post);    // you will get data for the li on which you click
});

3

solved Displaying individual post ids of queried columns in a php while loop with jquery [closed]