Reconciling Show/Hide JQuery Script into PHP -


i have php script outputs results query. add @ end 2 buttons show/hide final element, not sure how this.

the following php script:

while($result = mysqli_fetch_array($iname)) { echo "<b>event name:</b> " .$result['eventname']; echo "<br> "; echo "<b>location:</b> ".$result['location']; echo "<br>"; //this add 2 buttons, show "hidden" content when clicked 

and here have written in html script, reconcile php output:

<!doctype html> <html> <head> <scriptsrc="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js></script> <script> $(document).ready(function(){  $("#hidden").hide();  $("#hide").click(function(){     $("#hidden").hide(500); }); $("#show").click(function(){     $("#hidden").show(500); }); }); </script> </head> <body>  <button id="show">show</button> <button id="hide">hide</button>  <p id="hidden">  random text shown when buttons clicked  </p>  </body> </html> 

any suggestions how should done?

how if number of result rows $num_rows = mysql_num_rows($result); then, put counter in loop.

    $counter = 1;      $theclass="";      while($result = mysqli_fetch_array($iname))      {            if ($counter ==  mysql_num_rows($result);){      $theclass="showhide";      }      echo "<div class='$theclass'>";      echo "<b>event name:</b> " .$result['eventname'];      echo "<br> ";      echo "<b>location:</b> ".$result['location'];      echo "<br>";      echo "</div>        $counter++;      }

then, apply javascript div class="showhide"


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -