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

  • SEARCH
  • Home
  • 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 7493473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:59:01+00:00 2026-05-29T16:59:01+00:00

I have the following MySQL table: | id | Name | Windows | Linux

  • 0

I have the following MySQL table:

|  id   |    Name    |  Windows | Linux |
-----------------------------------------
|   1   |  Photoshop |     1    |   0   |
-----------------------------------------
|   2   |  Gimp      |     0    |   1   |

By clicking the above names as follows:

<a class="editlink" id="<?php echo $review['id']; ?>" href="#"><?php echo  $review['title']; ?></a>

I’m able to populate a form with the following JQuery code:

$(".editlink").click(function() {
    $.get("lists.php", {param2: $(this).attr('id')}, 
    function(data) {
        jsonOBJ = jQuery.parseJSON(data);
                for (var key in jsonOBJ) {
                     $(":input[name='" + key + "']").val(jsonOBJ[key]);
                }
        }   
);    
    return false;
});

And this is the form:

<form method ="post" action="review.php">   
    <input class="edit_title" type="text" size="51" value="" name="title"/><br/>
    <input type="checkbox" name="windows"/>
    <input type="checkbox" name="linux"/>
</form>

The LIST.PHP file is the following:

$qry = mysql_query("SELECT * FROM reviews JOIN filters ON reviews.id = filters.id WHERE reviews.id = ".$_GET['param2']." ");    
    while($review = mysql_fetch_array($qry)) {
        $arr = array('id_field' => $review['id'],
                     'title' => $review['name'],
                     'windows' => $review['Windows'],
                     'linux' => $review['Linux']
        );
    echo json_encode($arr);
}

But I don’t know how to check or uncheck the checkboxes accordingly to the boolean value (0 or 1) saved into the database.
For example, if JSON returns “windows”:”1″, how do I ‘convert’ this ‘1’ into ‘checked’?

  • 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-05-29T16:59:02+00:00Added an answer on May 29, 2026 at 4:59 pm

    UPDATED

    I would amend your PHP to return a boolean value for the checkbox fields like this:

    $qry = mysql_query("SELECT * FROM reviews JOIN filters ON reviews.id = filters.id WHERE reviews.id = ".$_GET['param2']." ");    
        while($review = mysql_fetch_array($qry)) {
            $arr = array('id_field' => $review['id'],
                         'title' => $review['name'],
                         'windows' => $review['Windows'] == "1",
                         'linux' => $review['Linux'] == "1"
            );
        echo json_encode($arr);
    }
    

    Then you can simply set the returned value as the checked attribute on the radio button:

    $(".editlink").click(function() {
        $.get(
            "lists.php", 
            { param2: $(this).attr('id') }, 
            function(data) {
                jsonOBJ = jQuery.parseJSON(data);
                for (var key in jsonOBJ) {
                    $(":input[name='" + key + "']").attr("checked", jsonOBJ[key]);
                }
            }   
        );    
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following mapping for my table in MySql: <class name=Tag, namespace table=tags
I have the following MySQL table: | id | Title | Windows | Linux
I have following mysql table: Item Name Listing Fee Listing Type watch $0.20 LISTED
I have the following MySql Table: -------------------------------------------- Table 'category' -------------------------------------------- category_id name parent_id 1
I have the following mysql table: Products ID -- NAME -- INSTOCK -- REFERER
I have following db structure in mysql. Table: Story Id Name categoryid date 1
I have the following tables in MySQL: team: id, name, [more stuff] person: id,
I have the following MySQL table structure: num field company phone website 1 Gas
I have the following table: mysql> SELECT * FROM `bright_promotion_earnings`; +----+----------+------------+----------+-------+ | id |
Lets say I have the following MySQL structure: CREATE TABLE `domains` ( `id` INT(10)

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.