new_php85 Posted September 9, 2008 Share Posted September 9, 2008 haii... im new in php.... i have table name record (id, location, noofday, rate). i want to do calculation betwen noofday and rate. eg: noofday * rate = amount. this is my example code $q2 = "SELECT noofday * rate AS amount FROM record WHERE id='$id'"; $result2 = mysql_query($q2) or die('Query failed. ' . mysql_error()); echo $result2 but it only appear Resource id #4. how come ya??? ??? ??? ??? Link to comment https://forums.phpfreaks.com/topic/123381-solved-how-to-calculate/ Share on other sites More sharing options...
The Little Guy Posted September 9, 2008 Share Posted September 9, 2008 $q2 = "SELECT noofday * rate AS amount FROM record WHERE id='$id'"; $result2 = mysql_query($q2) or die('Query failed. ' . mysql_error()); $row = mysql_fetch_array($result2); echo $row['amount']; Link to comment https://forums.phpfreaks.com/topic/123381-solved-how-to-calculate/#findComment-637270 Share on other sites More sharing options...
JasonLewis Posted September 9, 2008 Share Posted September 9, 2008 For an explanation, if you look at mysql_query() in the manual it has information about the return value. If you use something like a SELECT then it returns a MySQL Resource if it was successful or false on failure, this is why if you echo the query it will tell you the Resource ID #. Link to comment https://forums.phpfreaks.com/topic/123381-solved-how-to-calculate/#findComment-637294 Share on other sites More sharing options...
new_php85 Posted September 9, 2008 Author Share Posted September 9, 2008 $q2 = "SELECT noofday * rate AS amount FROM record WHERE id='$id'"; $result2 = mysql_query($q2) or die('Query failed. ' . mysql_error()); $row = mysql_fetch_array($result2); echo $row['amount']; thank you for your information... but why i got nothing for amount Link to comment https://forums.phpfreaks.com/topic/123381-solved-how-to-calculate/#findComment-637322 Share on other sites More sharing options...
new_php85 Posted September 9, 2008 Author Share Posted September 9, 2008 For an explanation, if you look at mysql_query() in the manual it has information about the return value. If you use something like a SELECT then it returns a MySQL Resource if it was successful or false on failure, this is why if you echo the query it will tell you the Resource ID #. thanks again... i got it Link to comment https://forums.phpfreaks.com/topic/123381-solved-how-to-calculate/#findComment-637336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.