Jump to content

trouble reading from table


ckdoublenecks

Recommended Posts

I'm trying to read the taxrate from the database table and use it with values from another table.  the database and table are correct as is the field (taxrate) from the table, value is 0.06.  Then I'm trying to multiply that value by the value of a field from another table (charges) then update the table . since it doesn't update, I tried echoing the two values but 0 is displayed for both.  Will someone advise me?

<?php
mysql_connect("localhost","root","");
mysql_select_db(numbersdb) or die( "Unable to select database"); 
$query = "SELECT taxrate FROM numbdata ";
mysql_fetch_assoc(mysql_query($query));
$result=mysql_query($query);
// include("getpercent.php");
$taxrate = $_POST['taxrate']; 
echo "taxrate ".$data['taxrate'];

mysql_connect(localhost,root,"");
mysql_select_db(oodb) or die( "Unable to select database");
$query = "SELECT id, tax,charges,datediff(curdate(),duedate) AS dayslate FROM oocust WHERE pd = ' '";
mysql_fetch_assoc(mysql_query($query));
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
     {
$id=$row['id']; 
$amtdue = $row['amtdue'];
$shipamt = $row['shipamt'];
$charges = $row['charges'];
$tax = $charges * $taxrate;
$amtdue = $charges + $tax + $shipamt;
echo "tax is $tax <br /><br />";
$days_late = ($row['dayslate'] > 0)?$row['dayslate'] : 0; 
$sql = "UPDATE oocust SET tax = " . $tax . ", amtdue = " . $amtdue . ", dayslate = " . $days_late . " WHERE 
id='$id'";
mysql_query($sql) ;
$err=mysql_error();
if($err!="")
     {
  echo "Error in $sql: $err\n";
      }
  }
echo "Invoice Prep completed";
?>

 

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.