Jump to content

Html Checkbox


nealios

Recommended Posts

Hello,

 

I have a single check box that will enable me to see whether to mark off if someone has paid there bill or not. The checkbox is part of a submit form that i can extract and add to my database using php and mysql.

 

I have set the checkbox up in the same way i would any other input text box.

 

Paid<input name =\"paid\" type=\"checkbox\" value=\"{$row['paid']}\" />

 

The db datatype is set up as Tinyint (1)

 

However i cant seem to get it into the db. Any pointers?

 

 

Many thanks

 

 

My form code is below

 

 

<form name=\"record_mod\" method=\"post\" action=\"jobadmin.php\">
<table border=\"1\" width=\"750\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td>
      <table border=\"0\" width=\"750\" cellspacing=\"0\" cellpadding=\"0\">
        <tr>
          <td align=\"left\">JobID: {$row['JobID']}</td>
        </tr>
      </table>
    
  <table border=\"0\" cellspacing=\"0\" cellpadding=\"4\">
        <tr>
          <td width=\"75\" align=\"right\">Start Date:</td>
          
	  <td colspan=\"3\">
	  
	  <input id=\"demo3\" type=\"text\" name=\"StartDate\" size=\"25\" value=\"{$row['StartDate']}\">  
	  <a  href=\"javascript:NewCal('demo3','ddmmyyyy')\"><img  src=\"cal.gif\" width=\"16\"  height=\"16\" border=\"0\"></a>
	  


	  
        </tr>
        <tr>
          <td width=\"75\" align=\"right\">End Date:</td>
          <td><input id=\"demo4\" type=\"text\" name=\"EndDate\" size=\"25\" value=\"{$row['EndDate']}\">  
	  <a  href=\"javascript:NewCal('demo4','ddmmyyyy')\"><img  src=\"cal.gif\" width=\"16\"  height=\"16\" border=\"0\"></a></td></tr>
          <td>Job Address 1:</td>
	  
          <td><input name=\"JobAddress1\" type=\"text\" size=\"30\" maxlength=\"20\" value=\"{$row['JobAddress1']}\" /></td>
	   <td>Job Address 2:</td>
          <td><input name=\"JobAddress2\" type=\"text\" size=\"30\" maxlength=\"20\" value=\"{$row['JobAddress2']}\" /></td>
        </tr>
      </table>
      <table border=\"0\" cellspacing=\"0\" cellpadding=\"4\">
        <tr>
          <td width=\"75\" align=\"right\">Postcode:</td>
          <td><input name=\"JobPostcode\" type=\"text\" size=\"40\" maxlength=\"25\" value=\"{$row['JobPostcode']}\" /></td>
        </tr>
        <tr>
          <td width=\"75\" align=\"right\">Price :</td>
          <td><input name=\"Price\" type=\"text\" size=\"40\" maxlength=\"25\" value=\"{$row['Price']}\" /></td>
        </tr>
      </table>
      <table border=\"0\" cellspacing=\"0\" cellpadding=\"4\">
        <tr>
          <td width=\"75\" align=\"right\">Description:</td>
          <td><input name=\"Description\" type=\"text\" size=\"20\" maxlength=\"25\" value=\"{$row['Description']}\" /></td>
          <td>Materials:</td>
          <td><input name=\"Materials\" type=\"text\" size=\"20\" maxlength=\"25\" value=\"{$row['Materials']}\" /></td>
       <td>Customer Id:</td> 
   
   <td><input name=\"cid\" type=\"text\" size=\"20\" maxlength=\"25\" value=\"{$row['cid']}\" /></td>
    <tr> <td>First Name:</td> 
	<td><input name=\"first_name\" type=\"text\" size=\"20\" maxlength=\"25\" value=\"{$row['first_name']}\" /></td></tr><td>surname:</td> 
	   <td><input name=\"surname\" type=\"text\" size=\"20\" maxlength=\"25\" value=\"{$row['surname']}\" /></td>
 <td>Paid<input name =\"paid\" type=\"checkbox\" value=\"{$row['paid']}\" /></td>


   
   
      </table>
     
      <hr align=\"left\" width=\"650\">
      <table border=\"0\" width=\"750\" cellspacing=\"0\" cellpadding=\"0\">
        <tr>
          <td align=\"left\">Process</td>
        </tr>
      </table>
      <table border=\"0\" cellspacing=\"2\" cellpadding=\"4\">
        <tr>
          <td><input name=\"op\" type=\"radio\" value=\"1\" /> Update Record</td>
          <td><input name=\"op\" type=\"radio\" value=\"2\" /> New Record</td>
          <td><input name=\"op\" type=\"radio\" value=\"3\" /> DELETE Record</td>
        </tr>
      </table>
      <table border=\"0\" cellspacing=\"2\" cellpadding=\"4\">
        <tr>
          <td colspan=\"3\"><a href=\"#\" onclick=\"record_mod.submit()\" class=\"button\"><span class=\"icon\"> Submit </span><a></td>
	  
	  
   
          <td><a href=\"jobs.php\" class=\"button\" span class=\"icon\"> Records List </span></a></td>      
          <td><a href=\"jobadmin.php?JobID=0&op=4\" class=\"button\" span class=\"icon\"> Synchronize</span></a></td>
	   <td style=\"padding-left: 50px;\">
           <td> <a href=\"jobadmin.php?JobID=$JobID&op=5&move=2\" class=\"button\" span class=\"icon\">Previous</span></a></td><td>Navigate</td>
  		   <td> <a href=\"jobadmin.php?JobID=$JobID&op=5&move=1\" class=\"button\" span class=\"icon\">Next</span></a></td>
          </td>
	  <td><a href=\"invoice.php?JobID={$row['JobID']}\" class=\"button\" span class=\"icon\"> Create Invoice </span></a></td> 
        </tr>
      </table>
    </td>
  </tr>
</table></p>
<input name=\"JobID\" type=\"hidden\" value=\"$JobID\" />
</form>";

Link to comment
Share on other sites

this is a php question....

 

you will need to check if the checkbox has been selected and if so update your database...

 

<?php

if (isset($_POST['paid']))
{
$qry = "UPDATE `yourtable` SET `yourfield` = 'y' WHERE `unique_id` = " . $uniqueid;
$qry = mysql_query($qry);
}
?>

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.