Jump to content

Updating field thru checkbox in a list


nestorvaldez

Recommended Posts

Hi...
I need to update an status Field in my table..
I have a List (select query) and one of the field in thelist is a checkbox form (this checkbox is a field in the table) I just need to adjust the status. If I marked the checkbox it save 1 and if it is unmarked it it will save 0. I use a bottom at the end of the form to make this update.
I found some code, but it doesn't  work.. I will show it, I hope I could get some help here.

This is some code in the List:

$updatelink="<p align=\"right\"><a href=\"actstatus.php?personal=$id&did=$did\">
<p align=\"right\"><img border=\"0\" src=\"../../images/actstatus.jpg\"alt=\"Update Docs Status\">";
echo ("$updatelink");

[actstatus.php]
<?php
include("../../functions/db.php");
$personal = $_GET['personal'];
$did = $_REQUEST['did'];


foreach ($did as $key => $value){
$p = "$value";
echo $p;
$query = mysql_query("UPDATE regdocu SET RDOC_STATUS=  WHERE RDOC_PERSONAL='$personal' AND RDOC_DOCU='$did'");
    }
if(!$query){
echo '<p><b><font face="Arial" color="#CE0808" style="font-size: 9pt">Error<span lang="es-do">:</span> </font></b>
<font face="Arial" style="font-size: 9pt" color="#CE0808">No se pudo actualizar status del Documento Contacte el administrador.</font></p>';
} else {
echo ("<meta http-equiv=\"refresh\" content=\"5; url=./fnuevo.php?id=$personal\">");
}

?>
Link to comment
Share on other sites

Checkboxes don't post (or get either) if they aren't checked. You should use a radio button, select box, or something else instead.

If you it has to be a checkbox, you can remove it from the form and have javascript change the value of a hidden field.

PS > I did read your code (and don't see a checkbox). Is this topic titled correctly?
Link to comment
Share on other sites

Yes I know About the SET in the STATUS, what I need to set is what I check in the checkbox in the list.If mark it I need to move 1 if I dont I what to move 0.
That is the only thing I need to do.. update in the table what i check.
But I dont know if the code is correct? Help me with this.....
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.