adamrg7 Posted August 28, 2009 Share Posted August 28, 2009 Hey everyone, I am new to the forum and its good to see a place to come for help.. I wouldn't say that I am a very experienced php/mysql programmer. I have more experience in c++, and I am just getting my hands dirty with php.. I need a little help retrieving some values, this is what I have so far, which it keeps giving me the same value 15 times for each userid: for ($counter=0; $counter<$totalAssets; $counter+=1) { for($counter2=0; $counter2<=15; $counter2+=1) { $longitudes_L = mysql_query("SELECT longitude FROM tbl_transactions where userid= '$assets[$counter]' ORDER BY tid DESC", $mysql_link); $theresult = mysql_fetch_row($longitudes_L); $longitudes[$counter][$counter] = $theresult[0]; echo $longitudes[$counter][$counter2]; } } Basically what im trying to do is get 15 of the last longitudes posted to the server, and put it into a multi dimensional array where the $longitudes[//THIS IS THE USER ID][//15 LONGITUDES go in here] Thanks.. -Adam Quote Link to comment https://forums.phpfreaks.com/topic/172311-retrieving-15-values-in-descending-order-starting-from-last-updated-need-help/ Share on other sites More sharing options...
Maq Posted August 28, 2009 Share Posted August 28, 2009 How does this relate to MySQL? Quote Link to comment https://forums.phpfreaks.com/topic/172311-retrieving-15-values-in-descending-order-starting-from-last-updated-need-help/#findComment-908517 Share on other sites More sharing options...
adamrg7 Posted August 28, 2009 Author Share Posted August 28, 2009 Sorry, i accidentally posted before i was done the message because i pressed TAB, and hit enter, which hit post. I modified the code, and there is mysql in there, hopefully you can help me out here with the best way to retrieve this data.. thanks Quote Link to comment https://forums.phpfreaks.com/topic/172311-retrieving-15-values-in-descending-order-starting-from-last-updated-need-help/#findComment-908519 Share on other sites More sharing options...
fenway Posted September 7, 2009 Share Posted September 7, 2009 I don't understand that logic whatsoever -- why not just issue a query with LIMIT 15? Quote Link to comment https://forums.phpfreaks.com/topic/172311-retrieving-15-values-in-descending-order-starting-from-last-updated-need-help/#findComment-914131 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.