|
Not logged in [Login - Register] |
You Are Not Registered Or Not Logged In |
Corsa Sport » Message Board » Off Day » Geek Day » Need some php gods help please » Post Reply
|
pow |
posted on 20th Apr 15 at 11:46 |
There is only maximum 300 lines in the csv, four bits of data (start time end time date and details), the csv is maximum 6kb, it loads just like any other light php page for me so I'm happy as it is. If it was loads of data I'd be doing it a little differently, however I cba to spend years on the school calendar lol | |
Dom |
posted on 19th Apr 15 at 22:18 |
quote: Hence the 'incredibly messy approach' comment ;):lol: Either way, it sounds like Pow is sorted which is the main thing :thumbs: | |
ed |
posted on 19th Apr 15 at 21:05 |
fseek() works using bytes and not lines; you'd need to know how many bytes each line contained to use it. There's some OO stuff built which lets you seek to a line number, but it works still works recursively to find the line in the file you want. | |
Dom |
posted on 19th Apr 15 at 20:50 |
quote: The fseek() function springs to mind (set pointer position, read X bytes; incredibly messy approach though) but I can't think of an elegant solution for CSV files in that you open the file and only grab X many rows from Y offset. Personally i would have just dumped the CSV into a DB table and gone from there :lol: But i know that doesn't fit every scenario. [Edited on 19-04-2015 by Dom] | |
ed |
posted on 19th Apr 15 at 20:31 |
Yah, but PHP's IO is a bit sucky. You're stuck going through the file recursively no matter what as you can't set the file pointer manually, like you can do in other languages. Once you open the file up, the whole thing will be there in an array so you may as well slice it. | |
Dom |
posted on 19th Apr 15 at 18:59 |
quote: That makes me feel a little 'dirty'* :lol: * I know, it depends on use, application etc etc | |
pow |
posted on 18th Apr 15 at 10:41 |
I've done it :cool: | |
pow |
posted on 17th Apr 15 at 16:26 |
Actually I'm managing to do it using a variable in the address as Steve suggested which is working nicely. You all may laugh but we gotta start somewhere! | |
pow |
posted on 17th Apr 15 at 16:07 |
Dave help me :cry: | |
ed |
posted on 17th Apr 15 at 15:53 |
This one's better :0 | |
DaveyLC |
posted on 17th Apr 15 at 15:51 |
e.g. http://www.jtable.org/Demo/PagingAndSorting | |
DaveyLC |
posted on 17th Apr 15 at 15:49 |
You'd be better off getting PHP to serve up the Data as JSON then use a JQuery UI paged table plug-in to display it. | |
ed |
posted on 17th Apr 15 at 15:44 |
Load the entire CSV into an array, then use array_slice() to get the parts of it you'd like. | |
pow |
posted on 17th Apr 15 at 15:13 |
It's not a DB backend though, it's a CSV - does that make a difference? I fucking hate websites! | |
Steve |
posted on 17th Apr 15 at 14:10 |
so the link for the next button may look like | |
Steve |
posted on 17th Apr 15 at 14:08 |
Easy, put the DB query limit in a variable that is set by a HTTP post and get variable containing a number that relates to the start/end you are interested in, then just dynamically generate the link for the button to contain the correct numbers. | |
pow |
posted on 17th Apr 15 at 13:40 |
I am useless with php, I mostly steal code from helpful people on the internet :lol: |