At a loss... |
[eluser]Jbeasley6651[/eluser]
I have a database table with about 10 fields i want to focus on 2 of the fields - 1 field containing a images base url, and 1 field containing number of images. Both fields are in same table. example field 1 url.com/imagename.jpg field 2 6 this means there are 7 images url.com/imagename.jpg url.com/imagename_2.jpg url.com/imagename_3.jpg url.com/imagename_5.jpg url.com/imagename_6.jpg How would i display this? I already have a foreach loop to show the other information in the table, would it be a foreach loop within a foreach loop? if so how would it look? Thanks in advance, Jbeasley
[eluser]Christoffer[/eluser]
Yes, you would need to make a foreach loop inside the foreach. Show me what you have and I can more easily help you with the exact code that would make it work as you intend ![]()
[eluser]@li[/eluser]
More like you'd write a for loop, e.g Code: for ($x=1; $x<=$field2; $x++) If this feels untidy to you, you could write a function in which you put your for loop, and in your foreach you simply call a function like Code: showImages($field2);
[eluser]Jbeasley6651[/eluser]
Thanks, my code is posted below. the field that contains the image base url is named photo_url the field that contains the quantity. photo_quantity Code: <?php foreach($listing_results->result() as $row) :?>
[eluser]Jbeasley6651[/eluser]
Figured it out! end result code was the following Code: <ul id="property_images"> First, the way it worked is they give you the image url like http://extimages2.living.net/ImagesHomeP...901483.jpg then they tell you there are lets say 5 images but then you have to access the images like this http://extimages2.living.net/ImagesHomeP...901483.jpg http://extimages2.living.net/ImagesHomeP...1483_2.jpg http://extimages2.living.net/ImagesHomeP...1483_3.jpg http://extimages2.living.net/ImagesHomeP...1483_4.jpg http://extimages2.living.net/ImagesHomeP...1483_5.jpg So what i ended up doing was some reg exp to take the string, replace everything before the mls id in this case A3901483 then taking that into a variable and rebuilding the file extension with the counter and just a static .jpg (they will always be .jpg) Thanks for pointing me in the right direction, Jbeasley |
Welcome Guest, Not a member yet? Register Sign In |