0

I have a table with column names ID&Reference . What I do in my query is I get the ID. And what I want to achieve is I want to add 000001 after the ID value and update the value of my Reference column with it.

For example: ID = 19 What I want to achieve is if ID = 19, -> Reference = 19000001.

But with my current code, what it does is add both values resulting to 000020 or if the ID = 1 the reference is updated with the value 2 (1 + 000001) instead of 1000001.

PS: Reference column is in int type on database.

$result = mysqli_query($con,$sql);
$sql = "select id from user_tbl where officer_name like '".$officer_name."';";
$result = mysqli_query($con,$sql);
if(mysqli_num_rows($result) > 0)
{
$row = mysqli_fetch_assoc($result);
  $oid = $row['id'];
}
$sql = "UPDATE user_tbl SET reference = '$oid' + '000001' WHERE id = '$oid'";
$result = mysqli_query($con,$sql);
Ekko Sky
  • 39
  • 1
  • 1
  • 10

0 Answers0