liamloveslearning Posted July 16, 2010 Share Posted July 16, 2010 Hi all, im trying to call a value from my DB and add the value of 1 to it, so if my db value was 20, id like it to be outputted in the browser as 21. Im having no luck googling so i thought id ask, is there a name for this function so I know what im looking for? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/207942-adding-1-to-value-called-from-db/ Share on other sites More sharing options...
liamloveslearning Posted July 16, 2010 Author Share Posted July 16, 2010 Ive tried this with no luck... <?php $d = $row_gethighestworld['intrajobno']; +1 ?> <?php echo $d; ?> Quote Link to comment https://forums.phpfreaks.com/topic/207942-adding-1-to-value-called-from-db/#findComment-1087034 Share on other sites More sharing options...
Pikachu2000 Posted July 16, 2010 Share Posted July 16, 2010 echo ($field + 1); Quote Link to comment https://forums.phpfreaks.com/topic/207942-adding-1-to-value-called-from-db/#findComment-1087037 Share on other sites More sharing options...
Pikachu2000 Posted July 16, 2010 Share Posted July 16, 2010 In the above, you have the addition operator outside the line termination. That's why it's giving you problems. Quote Link to comment https://forums.phpfreaks.com/topic/207942-adding-1-to-value-called-from-db/#findComment-1087038 Share on other sites More sharing options...
liamloveslearning Posted July 16, 2010 Author Share Posted July 16, 2010 Still no luck, its outputting 1 which is to say the addition isnt working :/ <?php echo ($row_gethighestworld['intrajobno'] + 1); ?> Quote Link to comment https://forums.phpfreaks.com/topic/207942-adding-1-to-value-called-from-db/#findComment-1087039 Share on other sites More sharing options...
Pikachu2000 Posted July 16, 2010 Share Posted July 16, 2010 Are you just getting the original value, or nothing at all? Quote Link to comment https://forums.phpfreaks.com/topic/207942-adding-1-to-value-called-from-db/#findComment-1087040 Share on other sites More sharing options...
liamloveslearning Posted July 16, 2010 Author Share Posted July 16, 2010 Im jsut getting the value 1, If i echo my variable however I get the value stored in the db Quote Link to comment https://forums.phpfreaks.com/topic/207942-adding-1-to-value-called-from-db/#findComment-1087041 Share on other sites More sharing options...
Pikachu2000 Posted July 16, 2010 Share Posted July 16, 2010 What does this show if you put it instead of the echo? echo '<pre>'; var_dump($row_gethighestworld['intrajobno']); echo '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/207942-adding-1-to-value-called-from-db/#findComment-1087042 Share on other sites More sharing options...
liamloveslearning Posted July 16, 2010 Author Share Posted July 16, 2010 It shows 'null', but <?php echo $row_gethighestworld['intrajobno']; ?> shows my value Quote Link to comment https://forums.phpfreaks.com/topic/207942-adding-1-to-value-called-from-db/#findComment-1087045 Share on other sites More sharing options...
Pikachu2000 Posted July 16, 2010 Share Posted July 16, 2010 Can you post the relevant code, from the db query through the end of the echo statement? Quote Link to comment https://forums.phpfreaks.com/topic/207942-adding-1-to-value-called-from-db/#findComment-1087046 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.