I am having trouble with multiplying variables that contain numbers any advice would be great. Current line that does the operation: $_SESSION['sppkgtotal'] = ($_SESSION['sppkgspecialqty']*$_SESSION['sppkgspecialprice'])+($_SESSION['sppkgwzoneqty']*$_SESSION['sppkgwindzoneprice']); It may just be that I have it written wrong .... Any thoughts would be great thank you.
This is how I grab the price could it be there? if(isset($_SESSION['sppkgspecial'])) { $_SESSION['sppkgspecialprice'] = mysql_query("SELECT price FROM sppkg WHERE description=$_SESSION[sppkgspecial]"); }
Try this if(isset($_SESSION['sppkgspecial'])) { $row = mysql_fetch_array(mysql_query("SELECT price FROM sppkg WHERE description='".$_SESSION['sppkgspecial']."'")); $_SESSION['sppkgspecialprice'] = $row['price']; } Code (markup):
$_SESSION['sppkgspecialqty']=(integer)$_SESSION['sppkgspecialqty']; $_SESSION['sppkgspecialprice']=(integer)$_SESSION['sppkgspecialprice']; $_SESSION['sppkgwzoneqty']=(integer)$_SESSION['sppkgwzoneqty']; $_SESSION['sppkgwindzoneprice']=(integer)$_SESSION['sppkgwindzoneprice']; $_SESSION['sppkgtotal'] = ($_SESSION['sppkgspecialqty']*$_SESSION['sppkgspecialprice'])+($_SESSION['sppkgwzoneqty']*$_SESSION['sppkgwindzoneprice']);
Great!! thank you ... now it rounds the values is that table of in the php? I don't want it to round if the price is 26.50 i want it to use 26.50 as the number to be multiplied? right now it used 27 even though the table says 26.50
for each session variable do this before you multiply them: $_SESSION['sppkgtotal'] = (isset($_SESSION['sppkgtotal'] )) ? (float) $_SESSION['sppkgtotal'] : 0