retrieve id of table rows?
<p>i have this script bellow to open table2 when clicking on the buttom 'more details' </p>

<pre><code> &lt;script&gt;
  $(document).ready(function() {

       $('#Table1 tr').click(function(event){

         $('#Table2').show();
         alert($(this).attr('id'));
       });
     });

&lt;/script&gt;
</code></pre>

<p>and this my code</p>

<pre><code> &lt;table id= "Table1" width='100%' border='1' cellspacing='0' cellpadding='0'&gt;
    $sql2=..
    $sql3 = blabla ;
    while($row3 =mysql_fetch_array($sql3)){
    $sql4 = mysql_query (" SELECT $ww as place FROM data WHERE $ww =".$row3[$ww]." and  id_user = ".$userid." ");
    $row4 = mysql_fetch_array($sql4) ;
    $string = "&lt;blink &gt; here  &lt;/blink&gt;" ;

    $wnumber = $row3[$ww] ;

     echo "&lt;tr id= '".$wnumber."'&gt;&lt;td  style= 'text-align : center ;'&gt;Week ".$row3[$ww]."
              &lt;/td&gt;" ;
     echo "&lt;td &gt;".(int) $row3["percent"] ."% &lt;/td&gt;";
     echo "&lt;td &gt; "?&gt;&lt;?php if($row4['place'] == 
     $row3[$ww] and $row2['id'] == $userid ){ echo $string ; } else { echo "";} ;?&gt;&lt;?php
     "&lt;/td&gt;";
     echo "&lt;td &gt;&lt;button class='showr'&gt;More Details&lt;/button&gt; &lt;/td&gt;&lt;/tr&gt;";
    //More Details when clicking on this buttom it open the table2
     }
   &lt;/tr&gt;
 &lt;/table&gt;
</code></pre>

<p>this is second table </p>

<pre><code> &lt;?php
    echo "&lt;div id= 'Table2' style= 'display:none;'&gt;";
    echo "&lt;table width='100%' border='1' cellspacing='0' cellpadding='0'&gt;";
    echo "&lt;th&gt; Week ".$wnumber."&lt;/th&gt;";
    echo "&lt;th&gt;try2&lt;/th&gt;";
    echo "&lt;tr &gt;&lt;td&gt;day&lt;/td&gt;";
    echo "&lt;td&gt;fff&lt;/td&gt;&lt;/tr&gt;";
    echo "&lt;/table&gt;&lt;/div&gt;";
 ?&gt;
</code></pre>

<p>*what i have now 5 rows with 5 buttoms . 
*what it happen now is when clicking on every bottom it echo same '$wnumber' lets say 6.
      however it defers from row to row ,
    - script works good with alert of the id of which row is clicked. 
   - only the last buttom who works with the last id of row.
*what i want is every bottom works with its row id which echo the right '$wnumber'
* what i have tried is (make variable in the div)</p>

<pre><code>   echo "&lt;div id= '".$wnumber."' style= 'display:none;'&gt;"; 
</code></pre>

<p>instead of </p>

<pre><code>    echo "&lt;div id= 'Table2' style= 'display:none;'&gt;"; 
</code></pre>

<p>but didnt work.</p>

<p>hope its clear and there is solution of it.</p>

<p>EDIT : this source code</p>

<pre><code>   &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;


    &lt;script&gt;
    $(document).ready(function() {

   $('#Table1 tr').click(function(event){

     $('#Table2').show();
     alert($(this).attr('id'));
   });
 });

  &lt;/script&gt;

  &lt;br /&gt;
  &lt;table id= "Table1" width='100%' border='1' cellspacing='0' cellpadding='0'&gt;
  &lt;th &gt;Weeks&lt;/th&gt;
 &lt;th &gt;&lt;p&gt;&lt;/p&gt;&lt;/th&gt;

 &lt;th &gt; Your place&lt;/th&gt;
 &lt;th &gt; More Details&lt;/th&gt;
&lt;tr&gt;
 &lt;tr id= '1'&gt;&lt;td  style= 'text-align : center ;'&gt;Week 1&lt;/td&gt;&lt;td style= 'text-align : 
  center ;'&gt;33% &lt;/td&gt;&lt;td  style= 'text-align : center ;'&gt; &lt;td style= 'text-align :  
  center ;'&gt;&lt;button class='showr'&gt;More Details&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr id= '6'&gt;&lt;td   
  style= 'text-align : center ;'&gt;Week 6&lt;/td&gt;&lt;td style= 'text-align : center ;'&gt;33%   
  &lt;/td&gt;&lt;td  style= 'text-align : center ;'&gt; &lt;td style= 'text-align : center   
  ;'&gt;&lt;button  
  class='showr'&gt;More Details&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr id= '13'&gt;&lt;td  style= 'text-align:   
  center ;'&gt;Week 13&lt;/td&gt;&lt;td style= 'text-align : center ;'&gt;33% &lt;/td&gt;&lt;td  style=   
  'text-align : center ;'&gt; &lt;blink style= 'color:#990000 ;font-weight: bolder;' &gt;  69   
  here &lt;/blink&gt;&lt;td style= 'text-align : center ;'&gt;&lt;button class='showr'&gt;More   
  Details&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tr&gt;

 &lt;/table&gt;
 &lt;br /&gt;
 &lt;div id= 'Table2' style= 'display:none;'&gt;&lt;table width='100%' border='1'  
  cellspacing='0' cellpadding='0'&gt;&lt;th&gt; Week 13&lt;/th&gt;&lt;th&gt;try2&lt;/th&gt;&lt;tr &gt;&lt;td&gt;day&lt;/td&gt;  
  &lt;td&gt;fff&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
  &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;
</code></pre>
