wxpsadd Posted October 30, 2008 Share Posted October 30, 2008 hi guys, can someone help how to MoveLast in php mysql? thanks in advance Link to comment https://forums.phpfreaks.com/topic/130681-got-problem-on-mysql/ Share on other sites More sharing options...
dezkit Posted October 30, 2008 Share Posted October 30, 2008 can someone help *insert adjective here* how to *insert verb here* with MoveLast in php mysql? Link to comment https://forums.phpfreaks.com/topic/130681-got-problem-on-mysql/#findComment-678177 Share on other sites More sharing options...
wxpsadd Posted October 30, 2008 Author Share Posted October 30, 2008 actually, in ASP its very easy to use movelast, the code below points on the last record in the database: set r = server.createobject("adodb.recordset") sql = "select * from tblsomething" r.open sql,c,1,3 r.movelast i can open, connect , databases and tables in mysql but i just dont know how to make movelast in php mysql any ideas how to do this? thanks in advance Link to comment https://forums.phpfreaks.com/topic/130681-got-problem-on-mysql/#findComment-678187 Share on other sites More sharing options...
alexweber15 Posted October 30, 2008 Share Posted October 30, 2008 geez would it kill you to try and answer the guys question? u assume you mean the MoveLast equivalent to the VB/.nET stuff (which afaik selects the last row in a database) in which case: SELECT col1, col2, col x FROM tablez ORDER BY abc DESC LIMIT 1 this would return exactly 1 row; the last one. if this isn't what you're looking for then yeah please try to be clearer! Alex Link to comment https://forums.phpfreaks.com/topic/130681-got-problem-on-mysql/#findComment-678189 Share on other sites More sharing options...
alexweber15 Posted October 30, 2008 Share Posted October 30, 2008 as for the PHP $dbh = new mysqli('localhost', 'root', 'root123', 'table123'); $sql = "SELECT * from tablex ORDER BY coly LIMIT 1 DESC"; $resultset = $dbh->query($sql); Link to comment https://forums.phpfreaks.com/topic/130681-got-problem-on-mysql/#findComment-678191 Share on other sites More sharing options...
wxpsadd Posted October 30, 2008 Author Share Posted October 30, 2008 thanks for the reply i got it now, problem solved thanks a lot, hope to help me next time thanks alex Link to comment https://forums.phpfreaks.com/topic/130681-got-problem-on-mysql/#findComment-678196 Share on other sites More sharing options...
alexweber15 Posted October 30, 2008 Share Posted October 30, 2008 np! Link to comment https://forums.phpfreaks.com/topic/130681-got-problem-on-mysql/#findComment-678875 Share on other sites More sharing options...
trq Posted October 30, 2008 Share Posted October 30, 2008 Actually, php's equivelent would be.... <?php $sql = "select * from tblsomething"; if ($result = mysql_query($sql)) { if ($row_count = mysql_num_rows($result)) { mysql_data_seek($result, $row_count-1); } } ?> The $result resource should now be sitting at the last pointer position. Link to comment https://forums.phpfreaks.com/topic/130681-got-problem-on-mysql/#findComment-678878 Share on other sites More sharing options...
alexweber15 Posted October 30, 2008 Share Posted October 30, 2008 true, i had no idea what MoveLast was so i did some quick research and for some reason assumed it just returned the last item in the result set (my solution) and not the entire result set with the internal pointer at the end (yours) Link to comment https://forums.phpfreaks.com/topic/130681-got-problem-on-mysql/#findComment-678892 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.