Show entries on per page is not working.
I fetched data for stock market from API request. my all data fetched successfully, but when i set data into jquery datatable, data insert successfully, but show entries on per page eg:- 10,25,100 is not working. entries paer page is set to by default same as it fetch from website, it is not changed. please help me to work it correctly.
index.php
<html>
<head>
</head>
<body>
<table class="table table-striped stocklist">
<thead>
<tr>
<th>Symbol</th>
<th>Date</th>
<th>open</th>
<th>High</th>
<th>Low</th>
<th>Close</th>
<th>Volume</th>
</tr>
</thead>
<?php
include('header.php');
$queryString = http_build_query([
'access_key' => '*********',
'symbols' => 'AAPL'
]);
// API URL with query string
$apiURL = sprintf('%s?%s', 'http://api.marketstack.com/v1/eod', $queryString);
// Initialize cURL
$ch = curl_init();
// Set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $apiURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute and get response from API
$api_response = curl_exec($ch);
// Close cURL
curl_close($ch);
$api_result = json_decode($api_response, true);
// Output of the API data
// print_r($api_result);
foreach ($api_result['data'] as $key=>$data)
{
?>
<tbody>
<tr>
<td><?php echo $data['symbol'] ?></td>
<td><?php echo $data['date'] ?></td>
<td><?php echo $data['open'] ?></td>
<td><?php echo $data['high'] ?></td>
<td><?php echo $data['low'] ?></td>
<td><?php echo $data['close'] ?></td>
<td><?php echo $data['volume'] ?></td>
</tr>
</tbody>
<?php }?>
</table>
</body>
</html>
<script>
$(document).ready(function(){
$('.stocklist').DataTable({
ordering: false,
searching: false
});
});
</script>
header.php
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="http://localhost/dsr/css/bootstrap.min.css">
<link rel="stylesheet" href="http://localhost/dsr/css/style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css"/>
<script type="text/javascript" src="//cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js"></script>
<!-- <script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap4.min.js"> </script> -->
</head>
</html>
question from:
https://stackoverflow.com/questions/65884317/datatable-shows-list-values-number-coming-from-api-select-entries10-25-not-wo 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…