The-Last-Escape Posted April 30, 2007 Share Posted April 30, 2007 have been lately trying to do mysql functions. I am just wondering why none of them have not been working, is there something I am doing wrong. I have tried using sum (the total amount of what is in rows) and LAST which is meant to get the last row that was entered, but nothing is working. $lastbills = "SELECT LAST(amount) FROM transactions WHERE type = 'Bill' AND userid = '" . $_SESSION['cymember'] . "' LIMIT 1;"; $lastbillq = mysql_query($lastbills); echo $lastbillsq; This is just one example of me trying to get the last occurence of something. I know queries aren't always the easiest to work with, but some of this stuff would be much simpler if I could get the hang of sql based specific functions that I can use straight in the query. Saving unnecessary time, I just have to learn to use them properly, any advice is greatly appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/49347-mysql-functions/ Share on other sites More sharing options...
Wildbug Posted April 30, 2007 Share Posted April 30, 2007 LAST() isn't a MySQL function. Link to comment https://forums.phpfreaks.com/topic/49347-mysql-functions/#findComment-241804 Share on other sites More sharing options...
Barand Posted April 30, 2007 Share Posted April 30, 2007 I've been unable to locate a LAST function, but here's an example using SUM() <?php $sql = "SELECT SUM(amount) as total FROM transactions WHERE type='Bill'"; $res = mysql_query($sql); // get query results $row = mysql_fetch_assoc($res); // get first (in this case the only) row echo $row['total']; // echo total field ?> Link to comment https://forums.phpfreaks.com/topic/49347-mysql-functions/#findComment-241810 Share on other sites More sharing options...
The-Last-Escape Posted April 30, 2007 Author Share Posted April 30, 2007 Alright ok thank you Link to comment https://forums.phpfreaks.com/topic/49347-mysql-functions/#findComment-241812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.