使用php从其他表数据中划分一个表数据

I had tried to display the divided value of saleprice from the table (additem) and from the table (addbill) data .i.e.quantity that we entered in the addbill table and display the value in the price column in addbill table.

Previously I was done to fetch from one table data from other table data

if(isset($_POST['submit1'])){
  $m = $_POST['itemname'];
  $sp = "SELECT saleprice FROM additem WHERE itemname='$m'";
  $q = mysqli_query($link,$sp);
  $n = mysqli_fetch_assoc($q);
  $saleprice = $n['saleprice'];
  $sql = "INSERT INTO addbill (bill_id,itemname,quantity,price) VALUES 
 ('".$_POST['billid']."','".$_POST['itemname']."','".$_POST['quantity']."','" .$saleprice."')";
  $result = mysqli_query($link,$sql);
  if ($result) {
    header("Location:addbill.php");
  }else{
    echo "error during adding";
  }
}

am not sure why you are using MySQL and mysqli both together, but for your concern, you have to calculate the new sale price before inserting records in database & then insert the calculated sale price instead of an original sale price.

$intSalesPrice = $saleprice * $_POST['quantity'];

You can calculate new sales prices like this.