Results 1 to 3 of 3

Thread: How to query multiple checkbox results stored in DB

  1. #1
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to query multiple checkbox results stored in DB

    Hi

    I have a form which calls checkboxes from MYSQL db table pages. I click on checkboxes that I want and it gets saved in the database table pages_blocks under field show_pages_id using the serialize() method. It saves the ID of pages table. Now I don't know how can I call the values back from the database table pages_blocks and validate them in the checkboxes, so that whatever ID stored in serialize method matches the ID pages table is CHECKED. Ofcourse using the unserialize method. But I just don't know how. Please do give me an example otherwise I won't know how.

    Simply I just want the serialized IDs saved in table pages_blocks to be shown as CHECKED when they are matched with IDs from table pages IDs.

    The code I am using to call is below and its not working at all. Notice the BOLD sentence, that I think has to be filled with all the ID's from table pages but I just don't know how to make it show there in the array. Please do tell me that too.
    Code:
    $qpagessh = "SELECT * FROM `acyn_pages_blocks` WHERE block_id = '$block__id'";
    $rpagessh = mysql_query($qpagessh);
    if (!$rpagessh){
    	die ("Could not query the database:<br />Houston! we have a problem here. ". mysql_error());
    }
    $row = mysql_fetch_array($rpagessh, MYSQL_ASSOC);
    
    $experiences = array('17', '18', '16', '15', '14'); I don't know what to put here so it queries everything from table pages
    
    $heat = unserialize($row['show_block_in_pages']);
    print_r($heat);
    for ($i = 0; $i < count($experiences); $i++){
    $checked = in_array($experiences[$i],$heat)? " checked" : "";
    echo "<input type=\"checkbox\" name=\"value[]\" value=\"$experiences[$i]\"$checked> $experiences[$i] <br>\n";
    }
    Thanks.
    Last edited by shyne; 08-08-2007 at 06:39 AM.

  2. #2
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Please help!

  3. #3
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Never mind I found my answer.

    Thanks anyways.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •