Im using PHP code to create a dropshadow effect on images.
I have this for-loop which basically gets an images size (width, height) and then adds a 1px drop shadow effect by using a for loop and its size.
for example:
for ($i=1; $i<=$height; $i++){
$display_table.="<img src='dropShadowLeft.jpg'><br>";
}
It works flawless on my computer (using wampserver). But when uploaded to the internet, it always skips a couple of these images, so instead of the dropShadow.jpg one of those squares where it says image not found (or whatever depending on browsers) shows instead.
Is the for loop too fast or something?
What do you think?
Thanks
The for loop isn’t too fast. That code generates HTML, and it’s the HTML that gets sent to the client. That will take as much time as it needs to transfer (well, unless the whole page times out, but that’s another story).
I’m not exactly sure the reason for the error, but I can tell you this is a terrible approach. Your browser has to make a request for every one of those images before it can display them (I think, or is it smart enough to recognize they’re the same and cache them?). Use one image and either tile it with CSS, or stretch it (if it’s one pixel, it’ll look fine). This means you don’t have to worry about needless extra requests, it produces cleaner and less HTML markup, and fix the problem.