Skip to main content
June 26, 2006
Answered

swap image within repeat region

  • June 26, 2006
  • 4 replies
  • 777 views
I'm trying to setup a swap image behaviour from within a repeat region dataset using php/mysql model. Anyone help? Cheers.
This topic has been closed for replies.
Correct answer
Thanks Rob, that's done it. Working code below.

<?php $i=1 //setup the dynamic ID number;
do { ?>
<a href="details.php?productCat=<?php echo $row_productCategory_rs['id_productCategory']; ?>&productID=<?php echo $row_productGroups_rs['id_product']; ?>" onmouseover="MM_swapImage('productImage','<?php $i; //add dynamic ID number here to make unique ?>','images/<?php echo ($row_productGroups_rs['image_product'])?>',1)" onmouseout="MM_swapImgRestore()"><?php echo $row_productGroups_rs['name_product']; ?></a><br />
<?php $i++; //increment the dynamic ID number } while ($row_productGroups_rs = mysql_fetch_assoc($productGroups_rs)); ?>

4 replies

Inspiring
June 27, 2006
You need to make sure that each image ID is unique in the repeating region
for the swap image to know which image to swap.
To do this, simply add a dynamic ID number (from the data being repeated in
the repeat region) to the end of the image ID value.

HTH
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
Dell stuff: http://robgt.com/dell
SatNav stuff: http://robgt.com/satnav



Correct answer
June 27, 2006
Thanks Rob, that's done it. Working code below.

<?php $i=1 //setup the dynamic ID number;
do { ?>
<a href="details.php?productCat=<?php echo $row_productCategory_rs['id_productCategory']; ?>&productID=<?php echo $row_productGroups_rs['id_product']; ?>" onmouseover="MM_swapImage('productImage','<?php $i; //add dynamic ID number here to make unique ?>','images/<?php echo ($row_productGroups_rs['image_product'])?>',1)" onmouseout="MM_swapImgRestore()"><?php echo $row_productGroups_rs['name_product']; ?></a><br />
<?php $i++; //increment the dynamic ID number } while ($row_productGroups_rs = mysql_fetch_assoc($productGroups_rs)); ?>
Inspiring
June 29, 2006
>load each swap image in during the loop as a 1x1pixel and therefore its
>loaded into the page and is ready to swap when needed

That would work too :)
Nice idea!

Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
Dell stuff: http://robgt.com/dell
SatNav stuff: http://robgt.com/satnav




Another thought I just had was that your method will add to the download
time slightly due to the images being "preloaded" but also resized to 1x1
pixel...

I don't know how much extra time it will take though, probably minimal to be
honest.

You could apply a class (CSS) to the 1x1 image to simply not display it at
all.

Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
Dell stuff: http://robgt.com/dell
SatNav stuff: http://robgt.com/satnav



Inspiring
June 26, 2006
And I have to leave for a client appointment. I'll check back when I return
and if you haven't solved it, I'll have a look at it.


--
Nancy Gill
Adobe Community Expert
BLOG: http://www.dmxwishes.com/blog.asp
Author: Dreamweaver 8 e-book for the DMX Zone
Co-Author: Dreamweaver MX: Instant Troubleshooter (August, 2003)
Technical Editor: DMX 2004: The Complete Reference, DMX 2004: A Beginner's
Guide, Mastering Macromedia Contribute
Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP Web Development


"pattam_" <webforumsuser@macromedia.com> wrote in message
news:e7p0kp$ks5$1@forums.macromedia.com...
> Yep have set that all up and the logic makes sense but it's not swapping
> the
> image. I suspect that this tech note has the answer but it doesn't refer
> to
> the php/mysql model so I can't follow it:
>
> http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_16510
>
>
>


June 26, 2006
Thanks I apprecieate it.....I'm not going to solve this one on my own!
June 26, 2006
Yep have set that all up and the logic makes sense but it's not swapping the image. I suspect that this tech note has the answer but it doesn't refer to the php/mysql model so I can't follow it:

http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_16510

Inspiring
June 26, 2006
You will have to have the image paths in columns in the database and then in
the Swap Image behavior, use the data source param rather than the name of
an image. Haven't tried this in PHP but it should work.


--
Nancy Gill
Adobe Community Expert
BLOG: http://www.dmxwishes.com/blog.asp
Author: Dreamweaver 8 e-book for the DMX Zone
Co-Author: Dreamweaver MX: Instant Troubleshooter (August, 2003)
Technical Editor: DMX 2004: The Complete Reference, DMX 2004: A Beginner's
Guide, Mastering Macromedia Contribute
Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP Web Development


"pattam_" <webforumsuser@macromedia.com> wrote in message
news:e7ovhh$jjd$1@forums.macromedia.com...
> I'm trying to setup a swap image behaviour from within a repeat region
> dataset using php/mysql model. Anyone help? Cheers.