Jump to content

whitemoss

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by whitemoss

  1. Hi all, I would like to write a code to immediately update the database, once a checkbox has been checked or unchecked. I already wrote a code for updating purposes but it didnt work as expected. It only brings the same value or id of checkbox even though I select other checkbox or select more than 1 checkbox. below is the code: <? $i = 1; $j = 1; while ($row = mysql_fetch_array($result)) { //while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $bil = $i; //+ ($PageaNo-1)*$PageSize; $id = $row['RecordID']; $date = $row['Date']; $event = $row['Event']; ?> <tr bgcolor="#CCCCCC"> <td align="center" width="50"><?php echo $bil; ?></td> <td align="center" width="50"><? echo "<input name='checkbox[$id]' id='$id' type='checkbox' value='$id'>"?></td> <td align="center" width="250"><?php echo $event; ?></td> <?php $i++; $j++; } ?> .... .... some codes here .... <td align="center"> <form name="form4" method="post" action="newPublicHoliday.php"> <input name="Add" type="submit" id="Add" value="Add Event"> </form> </td> <? if ($_POST['Submit']) { //$checkbox = $_POST["checkbox"]; $checkbox = $_POST['checkbox']; $id = $_POST['id']; echo $checkbox; echo $id; //foreach ($checkbox as $key => $value ) //{ //echo $id[$key]." ".$value; $update = "Update Holiday set Status=1 where RecordID=$id"; mysql_query($update); echo $update; //} } ?>
  2. I dunt insert any value for RecordID since it was an auto_increment but I still get the error.Below is my insert query. insert into mohelp(DateInsert,DateSend,MONumber,MobileNumber,Message,Status,TransID) values ('2005-02-14 10:07:56','2005-02-14 10:07:56 ','28882','0192426699','Help',1,'987654'); ERROR 1062: Duplicate entry '868648' for key 1
  3. Hi All, I tried to insert a data into a table but it didnt work. The error is: ERROR 1062: Duplicate entry '868648' for key 1 My table structure is: mysql> desc mohelp; +--------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+------------------+------+-----+---------+----------------+ | RecordID | int(10) unsigned | | PRI | NULL | auto_increment | | DateInsert | datetime | YES | | NULL | | | DateSend | datetime | YES | MUL | NULL | | | MONumber | varchar(20) | YES | | NULL | | | MobileNumber | varchar(20) | YES | MUL | NULL | | | Message | varchar(225) | YES | | NULL | | | Status | tinyint(1) | YES | | 0 | | | TransID | varchar(20) | YES | | NULL | | +--------------+------------------+------+-----+---------+----------------+ Hope anyone can help me regarding this matter.
×
×
  • 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.