Guys whats wrong in my code…Im trying to retrieve the value from database and store in html table…but only one value is inserted in the table and remaining values are not inserted …
Below is how my output looks like
Below is my php code
<?php
include 'db.php';
?>
<html>
<head>
<title>Inverter info</title>
<link rel="stylesheet" href="css/five.css">
<link rel="stylesheet" href="css/table.css"/>
<link rel="stylesheet" href="reference/bootstrap.min.css">
<script src="reference/jquery.min.js"></script>
</head>
<body>
<form method="post">
<div class="wrapper">
<div class="bg">
<div class="search-container">
<div class="search-bg"></div>
<div class="search">
<label for="dropdown">Inverter</label>
<select name="options" id="dropdown" class="selectpicker">
<option>Select The Inverter</option>
<option value="1">Inverter 1</option>
<option value="2">Inverter 2</option>
<option value="3">Inverter 3</option>
<option value="4">Inverter 4</option>
<option value="5">Inverter 5</option>
<option value="6">Inverter 6</option>
</select><br><br>
<input type="submit" class="btn btn-default" name="submit" onclick="show()">
<input type="reset" class="btn btn-default" value="Reset "><br/><br/>
<input type="button" data-toggle="modal" href="#myModal" class="btn btn-primary" name="Show Table" value="show Table" id="table">
</div></div></div></div>
<div id="myModal" class="modal fade in">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div class="table-title">
<h3>Inverter Details</h3>
</div>
<table class="table-fill" id="tabid">
<thead>
</div>
<div class="modal-body">
<tr>
<th class="text-left">Inverter</th>
<th class="text-left">TimeStamp</th>
<th class="text-left">Grid power total(W)</th>
</tr>
</thead>
<?php
if(isset($_POST["options"],$_POST["submit"]))
{
$inverter = $_POST["options"];
$query = "select * from inverterlog where inverter = '" . $inverter . "'";
$execute = mysqli_query($con,$query);
if($execute !== FALSE && mysqli_num_rows($execute)> 0)
{
while($row = mysqli_fetch_array($execute))
{
?>
<tbody class="table-hover">
<tr>
<td class="text-left"><?php echo $row['inverter']; ?></td>
<td class="text-left"><?php echo $row['timestamp']; ?></td>
<td class="text-left"><?php echo $row['gridpowertotal']; ?></td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<div class="btn-group">
<button class="btn btn-danger" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
</div>
<div class="btn-group">
<button id="change-chart" class="btn btn-primary"><span class="glyphicon glyphicon-check"></span>Save</button>
</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<?php
}
}
else
{
echo '<script language="javascript">';
echo 'alert("Data does not exist....")';
echo '</script>';
}
}
?>
</form>
<script>
</body>
</html>