1
我的angular.js代碼中有一個問題。我有一個表將填充數據庫值。當最初我的數據庫沒有價值和表應該顯示空白,但在我的情況下,現在的數據庫是空的表仍分爲5行沒有價值。我在下面解釋我的代碼。即使我的數據庫沒有值使用angular.js和PHP獲取多行
subject.html:
<table class="table table-bordered table-striped table-hover" id="dataTable">
<colgroup>
<col class="col-md-1 col-sm-1">
<col class="col-md-2 col-sm-2">
<col class="col-md-2 col-sm-2">
<col class="col-md-2 col-sm-2">
<col class="col-md-2 col-sm-2">
<col class="col-md-2 col-sm-2">
<col class="col-md-1 col-sm-1">
</colgroup>
<thead>
<tr>
<th>Sl. No</th>
<th>
<select style="width:100%; border:none; font-weight:bold;">
<option>Course Name</option>
</select>
</th>
<th>Semester</th>
<th>Subject Name</th>
<th>Short Name</th>
<th>Edit</th>
</tr>
</thead>
<tbody id="detailsstockid">
<tr ng-repeat="sub in subjectData" >
<td>{{ $index+1 }}</td>
<td>{{sub.course_name}}</td>
<td>{{sub.semester}}</td>
<td>{{sub.subject_name}}</td>
<td >{{sub.short_name}}</td>
<td>
<a href=''>
<input type='button' class='btn btn-xs btn-green' value='Edit'>
</a>
</td>
</tr>
</tbody>
</table>
subjectController.js:
var subApp=angular.module('GofastoHome');
subApp.controller('subjectcontroller',function($scope,$http){
$http({
method: 'GET',
url: "php/subject/readSubjectData.php",
}).then(function successCallback(response) {
console.log('response',response);
$scope.subjectData=angular.fromJson(response);
},function errorCallback(response) {
alert("could not fetch data");
});
})
這裏開始我的數據庫沒有value.When用戶耳目一新(i.e-subject.html
)的頁面中html表格中的表格分成5行,沒有da但5序列號即將到來,我不需要。請檢查我的PHP文件下面。
readSubjectData.php:
$connect = mysqli_connect("localhost", "root", "******", "go_fasto");
$result = mysqli_query($connect, "select * from db_subject order by subject_id desc ");
$data = array();
while ($row = mysqli_fetch_assoc($result)) {
$data[] = $row;
}
print json_encode($data);
我的要求是,只有當數據庫有一些value.When數據的數據庫表將被分裂爲空白它不應該對此我在我當前的代碼獲得。請幫幫我。