KirstyScott Posted January 14, 2009 Share Posted January 14, 2009 I'm trying to find out which people have the highest amount of a column in a table (by doing my code below), but each time i do this it displays the people with an amount in the column but dosen't order it by the column i want it too...below is my code :-X select top 15 COLUMN from TABLE order by COLUMN DESC Anyone know where im going wrong on this? the table itself has around 9 columns in total if that helps anyone And does anyone know how to insert a date using php into a database at the time it was inserted? ??? i'm just learning php as if you can't tell alrdy i'll appreciate any help! Quote Link to comment https://forums.phpfreaks.com/topic/140755-selecting-top-amount/ Share on other sites More sharing options...
revraz Posted January 14, 2009 Share Posted January 14, 2009 Post the actual query and the table structure. Also, you can use NOW() to insert the current date/time into MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/140755-selecting-top-amount/#findComment-736726 Share on other sites More sharing options...
Psycho Posted January 14, 2009 Share Posted January 14, 2009 Are you using MySQL? "TOP" is a SQL function not a MySQL function. You need to use LIMIT. SELECT * FROM `table` ORDER BY `column' DESC LIMIT 15 Quote Link to comment https://forums.phpfreaks.com/topic/140755-selecting-top-amount/#findComment-736734 Share on other sites More sharing options...
KirstyScott Posted January 14, 2009 Author Share Posted January 14, 2009 Ty all for trying to help I'm using SQL, and the NOW() function dosen't work for me, is there any other way to get a date inserted into the database/table using a php script? if so what? ??? Quote Link to comment https://forums.phpfreaks.com/topic/140755-selecting-top-amount/#findComment-736749 Share on other sites More sharing options...
uniflare Posted January 14, 2009 Share Posted January 14, 2009 unix_timestamps Effective, efficient and easy. time() will get you the current time and date in seconds (actually since unix epoch google it). you can store the result in db. then you can grab the date and time and format however u want to with date("d/m/y H:i:s",$old_timestamp); Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/140755-selecting-top-amount/#findComment-736753 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.