generating number multiples with coldfusion?

Discussion in 'Programming' started by ldexterldesign, Dec 11, 2007.

  1. #1
    hi guys,

    pretty stumped with this one. screenshot - http://www.personal.leeds.ac.uk/~scs4ll/Untitled-1.jpg

    firstly i have some code pumping out 2008 images at 1px high:

      <cfset totalLines = 2008>
      <cfloop from="1" to="#totalLines#" index="i">
        <cfset i = randrange(1, 2008)>
        <cfset i = numberformat(i, '0000')>
        <cfoutput><img src="pixelPics/#i#.jpg" alt="" /></cfoutput>
      </cfloop>
    Code (markup):
    then i have a value in a db that increments every time the page in question loads. i pull this value is as the variable 'totalPlainLines':

      <cfquery datasource="whereDoYouDrawTheLine" name="q2">
    SELECT NoLines AS totalPlainLines
    FROM NoLines
    </cfquery>
    Code (markup):
    basically i wanna pump out (duplicate) a plain white line for every value in the db. if the value stands at 15 i wanna pump out 15 white lines (the same sourced file, but 15 times). if the value is 330, then pump out a white line 330 times. my problem is how to do this whilst maintaining a randomized output of lines on the page. after all, i don't want a group of white lines and a group of coloured lines.

    i was thinking of doing something like this:

      <cfquery datasource="whereDoYouDrawTheLine" name="q2">
    SELECT NoLines AS totalPlainLines
    FROM NoLines
    </cfquery>
    
    <cfset aNumber = totalLines / q2.totalPlainLines>
    <cfset x = 2008 / 15<!---if 15 is the db value --->>
    <!--- now need to generate mutiples of x and append to a list --->
    
    
      <cfset totalLines = 2008>
      <cfloop from="1" to="#totalLines#" index="i">
        <cfset i = randrange(1, 2008)>
        <cfset i = numberformat(i, '0000')>
        <cfoutput><img src="pixelPics/#i#.jpg" alt="" /></cfoutput>
       <!--- cann then put an if statement in here checking to see if i == to a list multiple, if it is output a white line --->
      </cfloop>
    Code (markup):
    tips or hints would be life saving.

    :)
    lewis
     
    ldexterldesign, Dec 11, 2007 IP
  2. ldexterldesign

    ldexterldesign Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    s'ok. solved this one myself.

    lewis
     
    ldexterldesign, Dec 11, 2007 IP