Pagination Class and Simple Modal opens last picture only

Discuss coding issues, and scripts related to PHP and MySQL.
User avatar
JanMolendijk
Posts:282
Location:Holland Rotterdam

Pagination Class and Simple Modal opens last picture only

Dear Admin i`m buissy to add 15000 pictures on the website

I use your Pagination Class + I wanna use
For opening the info-pageby Simple Modal

I have on eatch page 20 pictures but when i click the modal-button
only one page is opening, the last picture from the 20.

This is my script

Code: Select all

<a href="'. $ar_page[$i]. '" rel="shadowbox"><img src="'. $ar_page[$i]. '" class="img-responsive" > </a><br>
   <form method="POST" action="../../18+/Lesbian-Kiss-Show-Picture.php?file='. $ar_page[$i]. '" target="_self" >                                             
          <input type="hidden" id="file" value="'. $ar_page[$i]. '">                            
          <input type="submit" value="Actions & Download">                                             
     </form>   
<button id="smodal1">Info</button>

<script>
var message = "<iframe src=/comments/18+/Lesbian-Kiss-Show-Picture.php?file='. $ar_page[$i]. ' width=100% height=40% frameborder=0 scrolling=yes align=top marginwidth=0 marginheight=0 name=offtopic></iframe>";

$("#smodal1").click(function(e) {
  // calls modal alert() method, with the message
  $.modal.alert(message);
});

// Calls modalW1(), passing win_cnt, on click the button
$("#smodal1").click(function (e) {
 modal1(win_cnt);
 return false;
});
</script>
This code upside is a part from this code

Code: Select all

  // receives an Arry with the content for all pages. Returns the content for the current page
  public function getArrRows($arr) {
    $startrow = $this->idpage * $this->rowsperpage;           // the element from which start to select
    $ar_page = array_slice($arr, $startrow, $this->rowsperpage);        // gets the elements for current page
    $nre = count($ar_page);
    $this->totalpages = ceil(count($arr) / $this->rowsperpage);        // sets the total number of pages
    $re ='okok';              // the variable that will be returned

    // HERE ADDS HTML TAGS TO FORMAT THE ZONE THAT CONTAINS EACH ELEMENT
for($i=0; $i<$nre; $i++) {
$re_cnt .='<script type="text/javascript">
Shadowbox.init();
</script><div class="col-xs-6 col-md-3"><div class="thumbnail">
<a href="'. $ar_page[$i]. '" rel="shadowbox"><img src="'. $ar_page[$i]. '" class="img-responsive" > </a><br>
   <form method="POST" action="../../18+/Lesbian-Kiss-Show-Picture.php?file='. $ar_page[$i]. '" target="_self" >                                             
          <input type="hidden" id="file" value="'. $ar_page[$i]. '">                            
          <input type="submit" value="Actions & Download">                                             
     </form>
<button id="smodal1">Info</button>
<script>
var message = "<iframe src=/comments/18+/Lesbian-Kiss-Show-Picture.php?file='. $ar_page[$i]. ' width=100% height=40% frameborder=0 scrolling=yes align=top marginwidth=0 marginheight=0 name=offtopic></iframe>";
$("#smodal1").click(function(e) {
  // calls modal alert() method, with the message
  $.modal.alert(message);
});

// Calls modalW1(), passing win_cnt, on click the button
$("#smodal1").click(function (e) {
 modal1(win_cnt);
 return false;
});
</script>
<iframe src="../../18+/Lesbian-Kiss-Count.php?file='. $ar_page[$i]. '" 
width="100" height="40" frameborder="0" scrolling="no" 
align="top" marginwidth="0" marginheight="0" name="offtopic">
</iframe>
<iframe src="../../18+/Lesbian-Kiss-Comment-Count.php?file='. $ar_page[$i]. '"
width="100" height="40" frameborder="0" scrolling="no"
align="top" marginwidth="0" marginheight="0" name="offtopic">
</iframe>
<div class="srtgs" id="rt_'. $ar_page[$i]. '"></div>
<div class="caption"></div>
</div></div>';
}
$re_cnt .='<link href="ratingfiles/ratings.css" rel="stylesheet" type="text/css" />
<script src="ratingfiles/ratings.js" type="text/javascript"></script>';
return $re_cnt;

    return $re;
  }

Admin Posts:805
Hello,
I not know how Simple Modal works, but mixing javascript code in php while() loop it can generate an incorrect html/js code, with multiple html elements with same id, and various time the same javascript variable. This will make that only the last repeated id and variable to be available.
- So, the javascript code for simple modal must be rewritted in your php script to not generate ID and JS variable repetitions due to while() loop.