hansman Posted June 30, 2008 Share Posted June 30, 2008 Hey here is my script for a calculator, i cant figure out how to implement the subract and division features. <form action="<? $_server['php_self']; ?>" method="get"> <p> <input name="hello" type="text" size="5" /> <select name="how"> <option value="*">X</option> <option value="+">+</option> <option value="-">-</option> <option value="/">%</option> </select> <input name="hello1" type="text" size="5" /> </p> <p> <input name="" type="submit" /> </p> </form> <?php $_GET['hello'] = $hello; $_GET['hello1'] = $hello1; $_GET['how'] = $whatone; echo $hello + $whatone + $hello1; ?> Link to comment https://forums.phpfreaks.com/topic/112658-simple-caluclator/ Share on other sites More sharing options...
DarkWater Posted June 30, 2008 Share Posted June 30, 2008 Firstly: You have the assignments backwards. Switch these around: $_GET['hello'] = $hello; $_GET['hello1'] = $hello1; $_GET['how'] = $whatone; Secondly: + is not the concatenation operator in PHP, . is. Third: If you're just doing two numbers then use a switch statement. Link to comment https://forums.phpfreaks.com/topic/112658-simple-caluclator/#findComment-578560 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.