PHP programming logic inquiry - php

With the help of this community, I just recently solved some issues with PHPExcel reading multiple files through a foreach(). Now it seems I've got logic issues.
I'm reading some excel files and extracting some data from them. This data are student grades. You can check a lightly modified code (I didn't paste it here because of quoting issues). $filelist is an array with the filenames available in the $folder I chose.
Now, while the first and fourth result show me the values of their respective files, all the other results do not (I've tried with 24 files so far). They show me the results from the first file.
What do you think might be happening here?
I guess it's a problem with the way I'm doing it, but I can't figure out the cause.
Thank you very much in advance.
PS: If you need any further data, please let me know. Thanks.

It must have been something within the files. I had a hard time redoing all the files into a single file with multiple sheets, and the program now works as intended.

Related

Generating pdf files from docx templates from mysql database

I've tried just about everything i could find so far. What i'm trying to do is save docx files in a mysql database, in which i want to replace a few strings and then convert it to a pdf file without any saving and put that in an html object element with application/pdf in the data tag.
I've tried phpword and gears\pdf but it was mostly outdated and even when i patched them up it still required saving the files in the website directory. I've looked at phpdocx, but as far as i can tell it's not exactly what i need and i'd rather not pay that much money without being sure it is.
So my questions are:
Is there any way at all to do this without having to buy phpdocx?
If not, is phpdoxc what i need?
If not, are there any resources i can use to figure out how these files are made up so i can make this conversion myself without any libraries?
I hope someone can help me, i'm getting really desperate

how to fill in excel table from PHP

I need some library or good documentation of xlsx files for writing out xls files from website. all I need to do is fill in content into predefined and styled table. I have considered writing everything directly from php but could't get hang of merging cells and if I could it would be a hell writing code for changing any style into a document instead its much better if I have predefined file uploaded and then just fill in.
Please redirect me or help me find some proper documentation.
Project is in early stage and can consider switching to other language like Node.js if it makes this part super easy but trying to keep it low profile prefer using PHP so i'm open to all ideas.
Thanks in advance to everyone.
PS. this is my first question on stackoverflow
Kindly do a Google search before posting questions like this. But answering your question, PHPExcel is a nice place to start. Just go through their documentation.

In PHP, is it possible to store multiple files within any type of container/archive?

The problem
We have approximately 5,500,000 small image files in 1000 different sub-categories, which as worked great until now. Unfortunately, our web host has some weird limitation to their server structure, that makes our current setup cause errors in their system.
They've now asked us to change our structure by limiting the total number of files to ~500,000, and I'm looking for a simple solution. The web host is great in other ways - has great support, great availability, cheap, etc., which makes us want to stay there. At least for now.
The question
Is it possible to, in some way, contain multiple files - all < 600 kB - in any type of container or archive, which is easily accessible using PHP?
More or less stupid ideas below.
Could you...
...store the files in a PHAR archive?
...convert 10-20 images at a time to strings and "shoving" them into a file, as, perhaps, a serialized array?
...store 10-20 images as a single large file and read out just the part that we need, given that we know the size of each image in this "container"?
I realize this is kind of a stupid question, since none of these ideas are good ideas. But I want to know if it's POSSIBLE to solve this in any other way than changing web host or uploading the images to a third party.
Thanks!

PHP save files to directory based on specific requirements

Sorry for (probably) kinda lame question, but i have been trying to figure this out for a kinda long time and for this, im too much of a beginner to solve this.
So i have a lot (hundreds) of excel files and im searching for a PHP script (or something else) that is able to move them into another directory.
Example:
files XAA, XBB, XCC, XDD etc belong to folder X files YAA, YBB, YCC,
YDD etc belong to folder y
It would be great if PHP would be capable of doing this, for example like "if the name contains "X" move it to folder X". I believe and hope it is, its really pain in the ass to do it manually.
Thank you good people of internet for any kind of help.

I have an entertaining "stuck file" issue

I'm in the process of creating a simple image admin tool that allows users to upload and delete images from a server. So far it's very basic stuff. I discovered that uploading files whose file name includes a blank space causes a problem - everything in the name up to the space is included in the uploaded file name, but nothing past that. The problem with this isn't so much broken image links (I can deal with those), but the images can't be deleted using my delete tool or the simplest "unlink" script. Once I discovered the problem and the cause, I contacted our support people and they cleared out the two problem files. Unfortunately, because of system constraints here at work, I don't have FTP access.
Now you'd think it's all resolved, but no. I added very clear warning messages - in bold red text - onto this prototype admin tool, and I let my boss and a few others know of the tool by email, explaining CLEARLY that file names with spaces don't work. So... what does my boss do? She uploaded two files with blanks in the file name.
So until I have a way to add an idiot filter into the script, can anyone suggest how I might be able to delete these two files? I'd even be willing to delete the populated directory and recreate it (none of the images there mean anything, just random stuff).
And if there's no advice about getting these things unstuck, is there any advice as to how I might prevent my boss from acting like a moron, short of cutting off her fingers?
my best answer would be, as you said, move all other files to another folder, delete folder, recreate folder.
After that, I'm thinking you need urlencode in your php to deal with weird characters and spaces in filenames.
One question that might help others, are you in Linux or Windows?
As a test, until it's working, try writing to a drive that you have access to so you can play until it works. Then switch to the live system. This way you don't have to call support to delete your tests.
Also, you could just substitute all spaces for underscores as a quick fix.
While deleting files using unlink() with their names having spaces in them, escape the spaces with "\". This will only work on Linux.

Categories