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
Parse error: syntax error, unexpected 'getval' (T_STRING) in C:\xampp\htdocs\Trying\fetch.php on line 43
which is var table = document.getElementById('getval');
almost at the end of the code.
`
<?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) > 0)
{
$output .= '<h4 align="center" class="h4_search">Search
Result</h4>';
$output .= '<div class="row">';
$output .= '<div class="col-md-8 col-md-offset-1 well">';
$output .= '<div class="table-responsive">
<table id="tbl" class="table table-bordered table-
striped table-hover">
<tr>
<th>Medicin Name</th>
<th>Price Per Sheet</th>
<th>Availble At</th>
<th>District</th>
<th>Area</th>
</tr>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
while ($row = mysqli_fetch_array($result)) {
$output .= '
<tbody id="getval">
<tr>
<td>'.$row['medicinName'].'</td>
<td>'.$row['pricerPerSheet'].'</td>
<td>'.$row['availAbleAt'].'</td>
<td>'.$row['district'].'</td>
<td>'.$row['place'].'</td>
</tr>
</tbody>
';
}
$output.='</table>';
$output.='<script>
var table = document.getElementById('getval');
for(var i=0; i<table.rows.length; i++){
table.row[i].onclick = function(){
alert(this.cells[0].innerHTML);
};
}
</script>
';
echo $output;
}
else
{
echo '<h4 align="center" class="h4_search">Data Not Found</h4>';
}
?>
`