0

This is php mysql code:

<?php $user_apply_data=mysql_query("SELECT * FROM apply");
 while ($user_apply_field = mysql_fetch_assoc($user_apply_data)) {  ?>
<tr>
<td><button class="btn btn-xs btn-success" id="apply" data-send="<?php echo $user_job_field['job_category']; ?>">Apply</button>
</td>
</tr>
 <?php } ?>

This is script:

$("#apply").click(function() {
            var check = $(this).data("send");
    alert(check);
            });

Output : first-row calling function rest are not

  • 2
    ***Please [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php).*** [These extensions](http://php.net/manual/en/migration70.removed-exts-sapis.php) have been removed in PHP 7. Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [PDO](http://php.net/manual/en/pdo.prepared-statements.php) and [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and consider using PDO, [it's really pretty easy](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Dec 07 '17 at 13:36
  • [ID's Must Be Unique](http://stackoverflow.com/questions/5611963/can-multiple-different-html-elements-have-the-same-id-if-theyre-different-eleme), specifically because it will cause problems in [JavaScript](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id) and CSS when you try to interact with those elements. – Jay Blanchard Dec 07 '17 at 13:36
  • `id="apply"` must be unique for all rows. You have identical IDs. – Nana Partykar Dec 07 '17 at 13:36
  • i make "apply" as a class and all work fine, Thank you for guiding. : and : $(".apply").click(function() { – Saket Vyas Ux Dec 07 '17 at 20:43

0 Answers0