lowe_22 Posted December 20, 2006 Share Posted December 20, 2006 Hi,I've run into a spot of difficulty whilst trying to code a script - I want to display 3 different images x number of times, where x is a number stored in a database.I'll tell you the context:I have a database of tournament wins with 4 columns: MemberID (which member has the wins...), 1st Places wins, 2nd place wins, 3rd place wins.A number is stored in each of the columns representing the number of each place won. I basically want to display an image for each one: 1image for 1st place, 1 image for second etc.. but I want to display that image however many times depending on the number in the database.For example, a member has 3 1st place wins, I want to display the image for a first place win 3 times on the page.How could I go about doing this?Thanks. Quote Link to comment Share on other sites More sharing options...
chiprivers Posted December 20, 2006 Share Posted December 20, 2006 Presuming you know how to extract the data from the database, you can do the following:[code]<?php$num = $row['number']; // you will need to amend $row['number'] to the correct reference from your table datafor ($x=0;$x<$num;$x++) {echo "<img src=\"image.gif\">";}?>[/code] Quote Link to comment Share on other sites More sharing options...
lowe_22 Posted December 20, 2006 Author Share Posted December 20, 2006 Yea, that helps a lot. thanks very much.There was one other thing that I could do with some help on. that is as follows:For every 10 images of a certain kind, a different image is displayed instead.So, if the member had 14 1st place wins, the browser should print one 10wins image followed by four 1stwins images.Understand?Any ideas?Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.