So, I want to show an image for each number in a certain variable (the variable is stock) So if there are 3000 in 'stock', 3000 of the image would be shown (I'm planning on small images, don't worry) Is it as simple as just putting the call to an img in a for loop? How would I do something that say, added a 'range' of where the image was as to avoid them all stacking on top of eachother? Also, I want to create a line graph based on three variables - total stock, total harvested and turns taken. The TOtal Stock and Total Harvested would be two different lines on the same graph and Turns would eb the X axis. Is there an easy-ish way to code this myself, or should I just google for some code for a graph and tie it into my code to receive my data?
Thanks for all the answers guys
Showing a bunch of images
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Showing a bunch of images
Are the graph and 3000 images two different things, or are they part of one component?
The indelible lord of tl;dr
Re: Showing a bunch of images
Jackolantern wrote:Are the graph and 3000 images two different things, or are they part of one component?
They'll use shared variables, but they are different entities.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Showing a bunch of images
Well, for showing 3000 images without having them all stack one after another, you would just use a nested FOR loop, like:
Just alter the FOR loops for the dimensions of the rectangle or to change the shape all-together.
As for the graph, I would download a 3rd party library to do that, as fabricating graphs from scratch that actually look decent isn't worth the time when there are so many graphing libraries out there already.
Code: Select all
for ($i = 0; $i < 50; $i++) {
for ($j = 0; $j < 60; $j++) {
echo "<img src=\"icon.jpg\">";
}
echo "<br>";
}As for the graph, I would download a 3rd party library to do that, as fabricating graphs from scratch that actually look decent isn't worth the time when there are so many graphing libraries out there already.
The indelible lord of tl;dr
Re: Showing a bunch of images
Use like nested CSS and the for-loops to create the rectangle and fill it up basically?Jackolantern wrote:Well, for showing 3000 images without having them all stack one after another, you would just use a nested FOR loop, like:
Just alter the FOR loops for the dimensions of the rectangle or to change the shape all-together.Code: Select all
for ($i = 0; $i < 50; $i++) { for ($j = 0; $j < 60; $j++) { echo "<img src=\"icon.jpg\">"; } echo "<br>"; }
As for the graph, I would download a 3rd party library to do that, as fabricating graphs from scratch that actually look decent isn't worth the time when there are so many graphing libraries out there already.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Showing a bunch of images
Use any CSS you need, but you can create a rectangle of images (or even a triangle with a more complex nested for loop) with just raw HTML in the PHP.
The indelible lord of tl;dr
Re: Showing a bunch of images
Duh ! I wasn't even thinking! Thanks alot jacko.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm