• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

Add links to dynamic Jquery slider

I have a Jquery slider working fine with the attached code. The images load from the database and the first image has the required class of 'active'

What i'm trying to do now is add a link but when I try this code with the link...

</div>  <div class="holder">
<div id="slideshow">

 <?php $counter = 1; do { ?>
     <a href="<?php echo $row_homeImages['link']; ?>"><img src="upload/<?php echo $row_homeImages['imageUpload']; ?>" alt="Lilles Market1"  width="923" height="290" class="<?php if ($counter++ == 1) echo 'active'; ?>" /></a>
<?php } while ($row_homeImages = mysql_fetch_assoc($homeImages)); ?> </div>

  </div></div>

 ...the first image just shows over again. How should I be adding the link here?
</div>  <div class="holder">
<div id="slideshow"> 

 <?php $counter = 1; do { ?>
     <img src="upload/<?php echo $row_homeImages['imageUpload']; ?>" alt="Lilles Market1"  width="923" height="290" class="<?php if ($counter++ == 1) echo 'active'; ?>" />
    <?php } while ($row_homeImages = mysql_fetch_assoc($homeImages)); ?> </div>

  </div></div>

Open in new window

0
BrighteyesDesign
Asked:
BrighteyesDesign
  • 4
  • 3
1 Solution
 
Lukasz ChmielewskiCommented:
Why not like this:

</div>  <div class="holder">
<div id="slideshow"> 

<?php 
   $counter = 1; 
   while ($row_homeImages = mysql_fetch_assoc($homeImages)){
?>
     <img src="upload/<?php echo $row_homeImages['imageUpload']; ?>" alt="Lilles Market1"  width="923" height="290" class="<?php if ($counter++ == 1) echo 'active'; ?>" />

    <?php $counter++; }  ?> </div>

  </div></div>

Open in new window

0
 
Lukasz ChmielewskiCommented:
Sorry, missed the if part:

</div>  <div class="holder">
<div id="slideshow"> 

<?php 
   $counter = 1; 
   while ($row_homeImages = mysql_fetch_assoc($homeImages)){
?>
     <img src="upload/<?php echo $row_homeImages['imageUpload']; ?>" alt="Lilles Market1"  width="923" height="290" class="<?php if ($counter == 1) echo 'active'; ?>" />

    <?php $counter++; }  ?> </div>

  </div></div>

Open in new window

0
 
BrighteyesDesignAuthor Commented:
Thanks for that,

That works in the same way as the original code. I can't seem to incorporate a link from the image.

Your code with an image link added gives you this...

http://www.travelstareuropean.com/NEW/indextest.php

Just the first image repeats



But without the link (code below) it's fine...

http://www.travelstareuropean.com/NEW/index.php



<?php 
   $counter = 1; 
   while ($row_homeImages = mysql_fetch_assoc($homeImages)){
?>
     <img src="upload/<?php echo $row_homeImages['imageUpload']; ?>" alt="Lilles Market1"  width="923" height="290" class="<?php if ($counter == 1) echo 'active'; ?>" />

    <?php $counter++; }  ?>

Open in new window

<?php 
   $counter = 1; 
   while ($row_homeImages = mysql_fetch_assoc($homeImages)){
?>
     <a href="test.html"><img src="upload/<?php echo $row_homeImages['imageUpload']; ?>" alt="Lilles Market1"  width="923" height="290" class="<?php if ($counter == 1) echo 'active'; ?>" /></a>

    <?php $counter++; }  ?>

Open in new window

0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
BrighteyesDesignAuthor Commented:
So just to recap, I need all the images to display and have links
0
 
Lukasz ChmielewskiCommented:
The images (at least with the code) seem to load fine - look at the source. I guess there's something wrong with the links attached to images. Can you post your jQuery here ?
Wrapping the images around with <a> tags changes the way jQuery looks up for the next element.
0
 
BrighteyesDesignAuthor Commented:
It was how Jquery treats links. Rather than persevere with this code I simply used another Jquery slider that supported links.

Just really of thought of that sooner!

Cheers for your help though.
0
 
Lukasz ChmielewskiCommented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now