Can't Update Please I need help

What is the structure of the tbl_courier table? What column name do the comments need to go in to?

@ikechukwuprosper20 I am not sure if this is about a update query, since I don’t see any values in the screenshot you showed But if you need to update the comments field as well this should work:

$sql_1 = "UPDATE `btbl_courier` 
             SET `status` = '$status', 
                 `comments` =  '$comments'
	       WHERE `cid` = $cid
	         AND `cons_no` = '$cons_no'";

I tried this but it didn’t work

Are you sure this is about the update query?

Why do you first have the insert query and right after that a update query?

Edit: Does the comments field has a default value in the database?

This is the update-success query

<tr>
        <td class="Partext1"><div align="center">
          <table cellpadding="4" cellspacing="0" align="center" width="70%">
<script language="javascript">
function validate()
  {
 if (form.Consignment.value == "" )
		 {
			alert("Consignment No is required.");
			form.track.focus( );
			return false;
		}
	}
</script>
            
              <tbody><tr>
                <td class="TrackTitle" valign="top"><div class="newtext" align="center"></div></td>
              </tr>
              <tr>
                <td class="bottom" valign="middle">&nbsp;</td>
              </tr>
              <tr bgcolor="EFEFEF">
                <td valign="top">Courier status updated  Successfully . <a href="courier-list.php">Click Here</a> To View all Courier List </td>
              </tr>
              <tr bgcolor="EFEFEF">
                <td class="TrackNormalBlue" bgcolor="#FFFFFF" valign="top">&nbsp;</td>
              </tr>
          </tbody></table>
        </div></td>
        </tr>
      <tr>
        <td class="Partext1">&nbsp;</td>
        </tr>

This is the value of the update query in the database

function dbQuery($sql,$dbConn)
{
	$result = mysqli_query($dbConn,$sql) or die(mysqli_error($dbConn));
	
	return $result;
}

Dit you see my last question? Does the comments field has a default value in the database

Can you show the structure of the table tbl_courier_track?

No it doesn’t have

What are the fields in the table tbl_courier_track?

You need to show the table. Do you use phpMyAdmin?

Yes I use phpMyAdmin

Can you please show me the structure of the table or tell me if the field comments have a default value

Can you show the content as well?

Click on browse and tell us what record it is about

The comments updates in phpMyAdmin but not on the site

Try to set the default value for comments to null and try it again. Otherwise I don’t see anything strange. I only don’t understand why you have an insert and updat query back to back

Edit: Also In the database all comment fields have a value of “Departed Post Office” But in the screenshot of the form I don’t see a value?

How do I set it null?

Isn’t the default already set to “None”, and the column set to not allow Nulls?

I’d presumed the tbl_courier_track is the transaction log, and tbl_courier is the current status, so each time a transaction is logged, it’s inserted into the first, and the status is updated to show the latest value, so a status enquiry doesn’t need to search through all transactions and get the status from the last one.

My questions are:

Are the latest comments supposed to be updated into the tbl_courier table? If they are, show the table layout for that table please?

If they are not, please show the HTML for the input form.

1 Like

I understand what you say, but why would someone update a field (comments) what they just added?

Edit: Then there should be in an insert for that secont table as well? Or am I wrong?