swanside Posted November 10, 2007 Share Posted November 10, 2007 Hi all, I am stuck now, I have a test database and I have made some search pages which return the results from a detail page when a specific item is clicked on. In one of the results field, there is a colume called addition_Cost. This is a percentage markup, but how do I get the info from this colume to put it into a variable to perform a maths sum? Cheers Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 10, 2007 Share Posted November 10, 2007 <?php $query = "SELECT addition_Cost FROM table_name WHERE (...not sure of your condition)"; $result = mysql_query($query)or die(mysql_error()); $row = mysql_fetch_assoc($result); echo $row['addition_Cost']; //This row holds the percentage from DB ?> If you want more specifics on the query condition, your going to have to explain more. How do you want to determine what row to pull the value from? Quote Link to comment Share on other sites More sharing options...
centerwork Posted November 11, 2007 Share Posted November 11, 2007 <?php $query = "SELECT addition_Cost FROM table_name WHERE (...not sure of your condition)"; $result = mysql_query($query)or die(mysql_error()); $row = mysql_fetch_assoc($result); echo $row['addition_Cost']; //This row holds the percentage from DB ?> If you want more specifics on the query condition, your going to have to explain more. How do you want to determine what row to pull the value from? To answer your question on how to add the % into a mathematical statement simply do the above, but when echoing out the $row do this. $percent = $row['addition_Cost']; //Then create your math phrase how you need it adding the variable. $math_result = 600*$percent; //Then display the results with this phrase. echo $math_result; If you have question just ask. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.