I want to pass some data when I run a query to add some data in mySQL 4 numeric fields which will be added to create a total. I have tried several ways to do this put nothing is working here is my code:
$custID = $_POST["custID"];
$cID1 = $_POST["cID1"];
$cTravelExp = $_POST["cTravelExp"];
$cLodgeExp = $_POST["cLodgeExp"];
$cFoodExp = $_POST["cFoodExp"];
$cOtherExp = $_POST["cOtherExp"];
$sqlSearch = "SELECT * FROM $tableName WHERE custID ='$custID' AND cID1= '$cID1' ";
$result = $conn->query($sqlSearch);
function addTotal($cLodgeExp,$cTravelExp,$cFoodExp,$cOtherExp){
$vacTotal = $cLodgeExp+$cTravelExp+$cFoodExp+$cOtherExp;
return $vacTotal;
}
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "Search results are "."Customer id: " . $row["custID"]." "."Yellowstone Plan Number: "." ".$row["cID1"]." "."First Name: ".$row["cFName"]." "." Last Name: " ." ".$row["cLName"]. " Plan Name: "
." ". $row["cPlanName"]." "." Travel Method ".$row["cTravel"]." Travel Expenses ".$row["cTravelExp"]. " Lodging Expenses ".$row["cLodgeExp"]." Food Expenses ".$row["cFoodExp"].
" Other Expenses ".$row["cOtherExp"]."<br>"."Total package price is ".addTotal($cTravelExp,$cLodgeExp,$cFoodExp,$cOtherExp);
}
My connection works but my total produces a zero every time?