EasyCFM.COM ColdFusion Forums / Coding Help! / working but need

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: working but need -- page: 1 2

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

specific
11-25-2007 @ 2:05 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 897
Joined: Apr 2006

hi, i was working on the random images module and completely successfully, and i was wandering that images should not repeat itself when they are displayed on the screen.

like i have four random images with their text displaying undernath it.

img1           img2          img3             img4
text1          text2         text3            text4


all are working properly as images appear randomly from the database and the folder as i query them

i want that if one img appear on row as img1 and that img should not appear again in same row twice.

i think my question is getting ambigious.

ok i say like:

if

img1       img2        img3       img4      

are all different

when they appear they should not be like:

img1         img3         img1          img4



hope u understand, what i am saying..

is tat possible with coldfusion

Thanks

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Door to Coldfusion Community Will Remain Open Till World Ends

Want a Web Portal Contact Me

randhawaz81@gmail.com

Ron
11-25-2007 @ 2:22 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 244
Joined: Oct 2004

Not sure I totally understand how you are getting  your random list of image names. If is from a database you can use the DISTINCT keyword to be sure not to get dups. Perhaps you can post some code that shoes how the list is generated

louissto56
11-25-2007 @ 2:26 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1149
Joined: Jan 2007

Can you post your query here

Notice-Board in NZ has now been released. Check it out at www.notice-board.co.nz !!

specific
11-25-2007 @ 2:39 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 897
Joined: Apr 2006

if it was possible to show a random image once and not again until the other images are shown.

my code is below:

<cfquery datasource="#dsn#" name="images">
SELECT property_id, property_file,
property_unique_name, property_hot,
property_features FROM
pd
WHERE property_hot = 1
ORDER BY property_id ASC
</cfquery>

Here i am generating it this way:

<cfset todays_images = Randrange(1,images.recordcount)>
<cfset todays_images1 = Randrange(1,images.recordcount)>
<cfset todays_images2 = Randrange(1,images.recordcount)>
<cfset todays_images3 = Randrange(1,images.recordcount)>
<table width="100%" border="0">
  <tr>
    <td>
          <table width="100%" border="0">
            <tr>
              <td width="25%"><img src="<cfoutput>#images.property_file[todays_images]#</cfoutput>" width="100" height="100" border="0" alt="Property which is Hot"> </td>
              <td width="25%"><img src="<cfoutput>#images.property_file[todays_images1]#</cfoutput>" width="100" height="100" border="0" alt="Property which is Hot"></td>
              <td width="25%"><img src="<cfoutput>#images.property_file[todays_images2]#</cfoutput>" width="100" height="100" border="0" alt="Property which is Hot"></td>
              <td width="25%"><img src="<cfoutput>#images.property_file[todays_images3]#</cfoutput>" width="100" height="100" border="0" alt="Property which is Hot"></td>
            </tr>





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Door to Coldfusion Community Will Remain Open Till World Ends

Want a Web Portal Contact Me

randhawaz81@gmail.com

This message was edited by specific on 11-25-07 @ 2:40 AM

Lossed
11-25-2007 @ 3:43 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1095
Joined: Apr 2004

try this in the SQL (if it's MySQL):

order by rand()
limit 4



Lossed
---------------------------
When the only tool you have is a hammer, everything looks like a nail Smile
-----------------------------

This message was edited by Lossed on 11-25-07 @ 3:51 AM

louissto56
11-25-2007 @ 4:06 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1149
Joined: Jan 2007

Lossed is right in that you should use SQL not CF but limiting it so it doesnt appear twice is a bit of a pickle. Try this. Not sure if it will work.

SELECT distinct property_id, property_file,
property_unique_name, property_hot,
property_features
FROM pd
WHERE property_hot = 1
ORDER BY rand()
LIMIT 4

If you are using Access then you can't use the distinct,rand or limit function lol.

Notice-Board in NZ has now been released. Check it out at www.notice-board.co.nz !!

specific
11-25-2007 @ 6:20 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 897
Joined: Apr 2006

i tried your way lossed and louis, but this does'nt seems to be working, the images appear again.

well i am using mysql but van not find a way with this:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Door to Coldfusion Community Will Remain Open Till World Ends

Want a Web Portal Contact Me

randhawaz81@gmail.com

gmilby
11-25-2007 @ 7:45 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 281
Joined: Nov 2007

i use this script some - will return whatever number of random images you need:

<cfquery datasource="#dsn#" name="GetRandomRecord">
select ...
from ...
</cfquery>

<cfset displayRow = randRange(4,GetRandomRecord.recordcount)>
<cfoutput query="GetRandomRecord" startrow="#displayRow#" maxrows="1">
#GetRandomRecord.RANDOM_FIELD_1# (SETUP WHATEVER FORMATTING THAT TURNS YOUR ROTOR) #GetRandomRecord.RANDOM_FIELD_1_text#
</cfoutput>     

this will output all 4 (see the 4 where randrange is set?) random records.

i hope this project is going to be opensource since you're asking for a lot of help from the open source community  Indifferent   maybe we could learn something from your project too(?)



=:All Hail, er - i mean "oh hell...":=

specific
11-25-2007 @ 8:06 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 897
Joined: Apr 2006

well mate, your approach works accordingly same way as mine and it is repeating images as again, so i think this  approach of urs is not a solution to the one..

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Door to Coldfusion Community Will Remain Open Till World Ends

Want a Web Portal Contact Me

randhawaz81@gmail.com

gmilby
11-25-2007 @ 8:47 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 281
Joined: Nov 2007

dude - it's working for me... i've never done it with '4' at a time, but it's working flawlessly - i'm wondering how you have this setup?

http://gcm.syr.edu/temp.cfm

here's the exact code i just used *moved the single quote to 4:

        <cfquery name="GetRandomRecord" datasource="randomquotes">
      SELECT *
        FROM famous_quotes
   </cfquery>
<cfset displayRow = randRange(4,GetRandomRecord.recordcount)>
<cfoutput query="GetRandomRecord" startrow="#displayRow#" maxrows="4">
#GetRandomRecord.file_name# <br /><small><em>Quoted by: #GetRandomRecord.author#</em></small><br>
</cfoutput>     

This message was edited by gmilby on 11-25-07 @ 8:55 AM

PAGE: 1 2
Sponsored By...
iOpenSoft, LLC is a Houston, Texas Advanced Technology Studio Specializing in Web Design, Web Development, iPhone App Development and Android App Development.