title: How to pass a PHP id to create two bootstrap button diffrent id's and use its for jquery functin?
body: <pre><code>&lt;?php
      include_once('config.php');
      $sql="SELECT * FROM events";                                                         
      $result = mysqli_query($con,$sql);
      if(!$result)
      {
       echo "no record found";
      }
      else
      {                                                                   
          while ($row =mysqli_fetch_assoc($result))
          {
           $e_id=$row['e_id'];         
      ?&gt;
                      &lt;?php 
                          $_SESSION['r']=$e_id."rr";
                          $_SESSION['l']=$e_id."ll";
                      ?&gt;
                  &lt;p&gt;
                      &lt;a class="btn btn-default" id="&lt;?php echo $_SESSION['r']; ?&gt;" role="button" data-toggle="collapse" href="#&lt;?php echo  $e_id; ?&gt;" aria-expanded="false" aria-controls="&lt;?php echo  $e_id; ?&gt;"&gt;View More &amp;raquo;&lt;/a&gt;
                      &lt;a class="btn btn-default" id="&lt;?php echo  $_SESSION['l']; ?&gt;" role="button" data-toggle="collapse" href="#&lt;?php echo  $e_id; ?&gt;" aria-expanded="false" aria-controls="&lt;?php echo  $e_id; ?&gt;"&gt;View Less &amp;laquo;&lt;/a&gt;&lt;/br&gt;
                  &lt;/p&gt;
  
  
  
                   &lt;script&gt;
                   var l = "&lt;?php echo $_SESSION['l'];?&gt;";
                   var r = "&lt;?php echo $_SESSION['r'];?&gt;";
                   alert(r);
                      $(document).ready(function(){
                        $("#"+r).show();
                        $("#"+l).hide();
  
                        $("#"+l).click(function(){
                          $("#"+l).hide();
                          $("#"+r).show();
                        });
  
                        $("#"+r).click(function(){
                          $("#"+r).hide();
                          $("#"+l).show();
                        });
                       });
                   &lt;/script&gt;
  
  
  &lt;?php        
          }//while
  
      }//else 
   ?&gt;
  </code></pre>
  
  <p>I fetch data $e_id from database then use it to create two buttons with added char to differ rr and ll as their id's then store in session. Now how to use it in jquery to show/hide each one. data-toggle on button is different div works fine. If i alert(r) gives 1rr 2rr 3rr, and alert(l) 1ll 2ll 3ll. I have 1,2,3 as id in database how can i use this button id's in script. session_start() was on top of page. The problem is hide/show not working guess I'm doing wrong. How can I call that id's properly?</p>