shyne
08-07-2007, 06:48 AM
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.
$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.
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.
$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.