How to search By Id in js : <p>I am trying to select row from dataTable,but there is a problem occur in js code under PHP.code is given bellow.Here firstly I fetched data from my database and then added them to dataTable.The code work perfectly till here..but when I  tried to select any row from the table it show an error sayin</p>

<p><strong>Parse error: syntax error, unexpected 'getval' (T_STRING) in C:\xampp\htdocs\Trying\fetch.php on line 43</strong></p>

<p>which is <code>var table = document.getElementById('getval');</code> almost at the end of the code.</p>

<p>`</p>

<pre><code>    &lt;?php
            $connect = mysqli_connect("localhost","root","","ajmal");
            $output = '';

            $sql = "SELECT                                              
            medicinName,pricerPerSheet,dealerID,availAbleAt,district,place 
            FROM medicinalinfo WHERE medicinName LIKE 
            '%".$_POST["search"]."%'";
            $result = mysqli_query($connect,$sql);


            if(mysqli_num_rows($result) &gt; 0)
            {
                $output .= '&lt;h4 align="center" class="h4_search"&gt;Search 
                Result&lt;/h4&gt;';
                $output .= '&lt;div class="row"&gt;';
                $output .= '&lt;div class="col-md-8 col-md-offset-1 well"&gt;';
                $output .= '&lt;div class="table-responsive"&gt;
                    &lt;table id="tbl" class="table table-bordered table- 
                    striped table-hover"&gt;
                        &lt;tr&gt;
                            &lt;th&gt;Medicin Name&lt;/th&gt;
                            &lt;th&gt;Price Per Sheet&lt;/th&gt;
                            &lt;th&gt;Availble At&lt;/th&gt;
                            &lt;th&gt;District&lt;/th&gt;
                            &lt;th&gt;Area&lt;/th&gt;
                        &lt;/tr&gt;';
               $output .= '&lt;/div&gt;';
               $output .= '&lt;/div&gt;';
               $output .= '&lt;/div&gt;';
               while ($row = mysqli_fetch_array($result)) {
               $output .= '
               &lt;tbody id="getval"&gt;
                    &lt;tr&gt;
                        &lt;td&gt;'.$row['medicinName'].'&lt;/td&gt;
                        &lt;td&gt;'.$row['pricerPerSheet'].'&lt;/td&gt;
                        &lt;td&gt;'.$row['availAbleAt'].'&lt;/td&gt;
                        &lt;td&gt;'.$row['district'].'&lt;/td&gt;
                        &lt;td&gt;'.$row['place'].'&lt;/td&gt;
                    &lt;/tr&gt;
               &lt;/tbody&gt;
             ';
             }
             $output.='&lt;/table&gt;';

             $output.='&lt;script&gt;

             var table = document.getElementById('getval');

             for(var i=0; i&lt;table.rows.length; i++){
                table.row[i].onclick = function(){
                    alert(this.cells[0].innerHTML);
                };
             }

             &lt;/script&gt;
          ';
          echo $output;
          }
        else
        {
           echo '&lt;h4 align="center" class="h4_search"&gt;Data Not Found&lt;/h4&gt;';
        }


     ?&gt;
</code></pre>

<p>`</p>
