hayesb2 Posted April 9, 2008 Share Posted April 9, 2008 This is likely simple for most but I'm learning... I have a mysql database, and in the table "products" is a column for "products_price". How do I write the php code to update all of the prices values in the database so they are 15% higher? Quote Link to comment Share on other sites More sharing options...
paul2463 Posted April 9, 2008 Share Posted April 9, 2008 $query = "UPDATE tablename SET pricecolumn = pricecolumn * 1.15"; Quote Link to comment Share on other sites More sharing options...
hayesb2 Posted April 9, 2008 Author Share Posted April 9, 2008 Thank you and what if I wanted to subtract 15%? Last question Quote Link to comment Share on other sites More sharing options...
paul2463 Posted April 9, 2008 Share Posted April 9, 2008 you would do the same maths for adding 15% to do the subtraction $query = "UPDATE tablename SET pricecolumn = pricecolumn - 15%"; //however you do that math Quote Link to comment Share on other sites More sharing options...
hayesb2 Posted April 9, 2008 Author Share Posted April 9, 2008 The thing is I dont know the syntax to do minus 15% Quote Link to comment Share on other sites More sharing options...
paul2463 Posted April 9, 2008 Share Posted April 9, 2008 thats maths syntax to make that happen and I dont know what it is it may be $query = "UPDATE tablename SET pricecolumn = pricecolumn - ((pricecolumn/100)*15)"; Quote Link to comment Share on other sites More sharing options...
fenway Posted April 9, 2008 Share Posted April 9, 2008 Or "= ROUND( 0.85 * pricecolumn, 2 )" 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.