for example i have:
<?php foreach($query as $q): ?>
<div class="item">
<?php echo img($q->images); ?>
</div>
<?php endforeach; ?>
so this code renders 5 divs in a line, each line 5 divs, and this code:
<?php foreach($url->result() as $u): ?>
<script>
$(document).ready(function(){
$('div.item').click(function(){
setTimeout(function(){
window.open('<?php echo $u->url; ?>');
}, 500)
})
})
</script>
<?php break; ?>
<?php endforeach; ?>
doesn't matter what div we click, it will open a new window with the same url, but what if I have 5 different urls in my database, and I want that when we click the first div of each line it open one window with the first url and when we click the second it will open the second url
i thinked that this is possible by using classes, for example class="item1", item2, item3, item4, item5, but what if we have only 3 urls, not 5, in this case how can i make that the first three divs will open the first 3 urls, but the 2 left, will open the last, it is the 3 div
sorry for my poor english, maybe you have an idea of how to do this, thanks!
ps: i am using codeigniter