kumashiru Posted February 5, 2006 Share Posted February 5, 2006 Is there anyway using php to add, multiply, subtract, etc, integer inside a mysql table?example..id|name|int1|int2|int3[!--sizeo:2--][span style=\"font-size:10pt;line-height:100%\"][!--/sizeo--]1| john | 3 | 2 | 4 2| mary | 5 | 3 | 4[!--sizec--][/span][!--/sizec--]and i need to subtract john, int1, from mary, int4 and display it for the user to see (display, but not change the data inside the table)all the numbers are predefined in the table, and there's noway for the user to change them.any help? Quote Link to comment https://forums.phpfreaks.com/topic/3333-equations-with-integers-in-mysql/ Share on other sites More sharing options...
fenway Posted February 6, 2006 Share Posted February 6, 2006 Huh? The MySQL parser can do math (e.g. int1-int4), but it won't work _across_ rows. You'd have to do some fancy joins for that... it'll get complicated. Maybe you can explain further? Quote Link to comment https://forums.phpfreaks.com/topic/3333-equations-with-integers-in-mysql/#findComment-11369 Share on other sites More sharing options...
kumashiru Posted February 6, 2006 Author Share Posted February 6, 2006 hmm.. i see it can get complicated.well then, is taking data from mysql table and turning it into a php $variable possible without using post/submit? Quote Link to comment https://forums.phpfreaks.com/topic/3333-equations-with-integers-in-mysql/#findComment-11371 Share on other sites More sharing options...
fenway Posted February 6, 2006 Share Posted February 6, 2006 Of course -- you can always retrieve data and store it in PHP variables. How do you mean? Quote Link to comment https://forums.phpfreaks.com/topic/3333-equations-with-integers-in-mysql/#findComment-11372 Share on other sites More sharing options...
kumashiru Posted February 6, 2006 Author Share Posted February 6, 2006 Using the (badly aligned) example above, store int2 from id1, and int2 from id2 into $variable1 and $variable2 then use that to add/multiply/whatever?how would i go about putting them into variables?I know I can do this with post/submit deal, but i'm trying to avoid using that. Quote Link to comment https://forums.phpfreaks.com/topic/3333-equations-with-integers-in-mysql/#findComment-11382 Share on other sites More sharing options...
fenway Posted February 6, 2006 Share Posted February 6, 2006 I don't understand -- just run a SELECT statement, and store the results in PHP. Quote Link to comment https://forums.phpfreaks.com/topic/3333-equations-with-integers-in-mysql/#findComment-11386 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.