wxpsadd Posted October 30, 2008 Share Posted October 30, 2008 hi guys, can someone help how to MoveLast in php mysql? thanks in advance Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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); Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
alexweber15 Posted October 30, 2008 Share Posted October 30, 2008 np! Quote Link to comment 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. Quote Link to comment 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) Quote Link to comment 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.