Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8287917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:10:10+00:00 2026-06-08T12:10:10+00:00

I have a table with records from a database which is dynamically filled. <table>

  • 0

I have a table with records from a database which is dynamically filled.

<table>
<tr>
   <td>name
   </td>
   <td>surname
   </td>
   ...
</tr>
<?php do { ?>
<tr>
    <td><?php echo $row_Recordset1['Name'];?>
    </td>
    <td><?php echo $row_Recordset1['Surname'];?>
    </td>
...
<td align="center">
    <form name="form" action="novi.php">
    <input name="check" type="radio" value="da">Да
    <input name="check" type="radio" value="ne">Не
    <input type="hidden" id="id" value="<?php echo $row_Recordset1['id_korisnici'];?>">
    <input class="button1"type="button" id="klik" value="Испрати"/>
    </form>
</td>
</tr>
<?php } while($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>

And than I’m using J Query to create an AJAX call to another page which will run the query.

<script>
$('#klik').click(function() {
var check = $("input[name='check']:checked").val();
var id = $('#id').val();
if (check == "da")
{
    $.post('sluzbaIncludes/n.php', {check:check, id:id}, function(data) {

        $('#klik').prop('value', (data));
        document.location.reload();

    });
}
else if (check == "ne")
{
    $.post('sluzbaIncludes/n.php', {check:check, id:id}, function(data) {

    $('#klik').prop('value', (data));
    document.location.reload();

});
}
else
{
    $('#klik').prop('value', 'Грешка');
    setTimeout("$('#klik').prop('value', '.')",500);
    setTimeout("$('#klik').prop('value', '..')",1000);
    setTimeout("$('#klik').prop('value', '...')",1500);
    setTimeout("$('#klik').prop('value', 'Испрати')",2000);

}

});

This is working OK if there is only one row in the table.
What I don’t know how to do is, to make the script store all the generated CHECKED radio buttons in an array or something, plus all the ID’s of the records from the database and send them to another page where according to their ID’s a query will update the database..

<?php
if ($_POST['id'] != NULL) {
if ($_POST['check'] == "da") {
       $id = mysql_real_escape_string($_POST['id']);
   $update = mysql_query("update korisnici set validacija = 1 where id_korisnici= '$id'");
        if ($update === true) {
        echo 'OK';

    }else if ($update === false){
        echo 'Error!!!';
    }
}
elseif ($_POST['check'] == "ne")
{
$id = mysql_real_escape_string($_POST['id']);
    $update = mysql_query("update korisnici set validacija = 2 where id_korisnici= '$id'"); 
    if ($update === true) {
            echo 'OK';

        }
    else if ($update === false){
            echo 'Error!!!';
        }
}
} else {
echo 'Error!!!';
}
?>

Thanks!
P.S. I’m a noob in JQuery and a beginner in PHP…

UPDATE:

I did change some things. And now the values are shown as I want, when I click the button without a selection I’m getting the error message in the ELSE part of the JQuery code in the proper button. But no matter which button I click (if the table is populated with 3 records from the database, there are 3 buttons) only the first row from the table is updated in the database.

<form name="form" action="novi.php">
           <input name="check<?php echo $row_Recordset1['id_korisnici'];?>" type="radio" value="da">Да
           <input name="check<?php echo $row_Recordset1['id_korisnici'];?>" type="radio" value="ne">Не
           <input type="hidden" id="id" value="<?php echo $row_Recordset1['id_korisnici'];?>">
           <input class="button1"type="button" id="klik<?php echo $row_Recordset1['id_korisnici'];?>" value="Испрати"/>
            </form>

The JQuery:

$('#klik<?php echo $row_Recordset1['id_korisnici'];?>').click(function() {
var check = $("input[name='check<?php echo $row_Recordset1['id_korisnici'];?>']:checked").val();
var id = $('#id').val();


if (check == "da")
{
    $.post('sluzbaIncludes/n.php', {check:check, id:id}, function(data) {

        $('#klik<?php echo $row_Recordset1['id_korisnici'];?>').prop('value', (data));
        document.location.reload();

    });
}
else if (check == "ne")
{
    $.post('sluzbaIncludes/n.php', {check:check, id:id}, function(data) {

    $('#klik<?php echo $row_Recordset1['id_korisnici'];?>').prop('value', (data));
    document.location.reload();

});
}
else
{
    $('#klik<?php echo $row_Recordset1['id_korisnici'];?>').prop('value', 'Error');
    setTimeout("$('#klik<?php echo $row_Recordset1['id_korisnici'];?>').prop('value', '.')",500);
    setTimeout("$('#klik<?php echo $row_Recordset1['id_korisnici'];?>').prop('value', '..')",1000);
    setTimeout("$('#klik<?php echo $row_Recordset1['id_korisnici'];?>').prop('value', '...')",1500);
    setTimeout("$('#klik<?php echo $row_Recordset1['id_korisnici'];?>').prop('value', 'Send')",2000);

}

});

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:10:11+00:00Added an answer on June 8, 2026 at 12:10 pm

    Make each group of radio buttons have a unique name but the same class. Then you can iterate through them using jQuery:

    var radioVals = new Array();
    var i = 0;
    $(".radioButtonClass:checked").each(function() { 
        radioVals[i] = $(this).val();
    });
    

    Then just pass the array in your ajax call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a drop down list which is populated dynamically from database table i.e
I am from Indonesia.. I have a table in database which it's name tb_schedule
I have the following Django Model which retrieves 3 records from a database. The
I have loaded an associative array of records from a MySQL database table. The
I have a table in my database which has duplicate records that I want
Situation: In my database I have a table in which records may reference other
I have a table in my database in which records conceptually can be children
I have a database DB and I want to delete records from table MyRecords
I have table a joining table b, I only want the records from table
I have table with 300 000 records (MyISAM). I get record from this table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.