Comments (12)
First, you can query data from MySQL and return data you need.
For example, your.php
:
$limit = $_GET['limit'];
$offset = $_GET['offset'];
... // http://www.tutorialspoint.com/php/mysql_select_php.htm
echo json_encode(array(
'total' => 800, // select count(*) from table ...
'rows' = $rows // select * from table limit ...
));
And then:
// http://wenzhixin.net.cn/p/bootstrap-table/docs/examples.html#server-side-pagination-table
<table data-toggle="table" data-url="your.php">
...
</table>
Hope to help you.
from bootstrap-table.
Hi Bro,
Thanks for your answer, i have troubles, i create the php script and put de data-url="my.php" but don't show me my data info.
This is my php script...
<?php
$sql = "SELECT nit, nom_empre, ciudad_empre, telef_empre, sitio_web, clasi_empre, dir_empre, macrosector, sector, sector2, baseM, ventas2012, activos2012, nomb_cont, cargo_cont, dep_cont, email_cont, ciudad_cont, base_cont, tel_exte, nit_cont, empre_cont FROM empresa, contactos";
function connectDB(){
$server = "server";
$user = "user";
$pass = "pass";
$bd = "bd";
$conexion = mysqli_connect($server, $user, $pass,$bd);
if($conexion){
echo 'La conexion de la base de datos se ha hecho satisfactoriamente';
}else{
echo 'Ha sucedido un error inexperado en la conexion de la base de datos';
}
return $conexion;
}
function disconnectDB($conexion){
$close = mysqli_close($conexion);
if($close){
echo 'La desconexion de la base de datos se ha hecho satisfactoriamente
';
}else{
echo 'Ha sucedido un error inexperado en la desconexion de la base de datos
';
}
return $close;
}
function getArraySQL($sql){
//Creamos la conexi贸n con la funci贸n anterior
$conexion = connectDB();
//generamos la consulta
mysqli_set_charset($conexion, "utf8"); //formato de datos utf8
if(!$result = mysqli_query($conexion, $sql)) die(); //si la conexi贸n cancelar programa
$rawdata = array(); //creamos un array
//guardamos en un array multidimensional todos los datos de la consulta
$i=0;
while($row = mysqli_fetch_array($result))
{
$rawdata[$i] = $row;
$i++;
}
disconnectDB($conexion); //desconectamos la base de datos
return $rawdata; //devolvemos el array
}
$myArray = getArraySQL($sql);
echo json_encode($myArray);
?>
Thanks men for your help...
from bootstrap-table.
Hi,
You can use browser open the URL(my.php) directly, and then compare with the data (http://wenzhixin.net.cn/p/bootstrap-table/docs/data1.json).
from bootstrap-table.
Hi bro,
Thanks for you answer, but i don麓t understand the porpous to do that? if my script looks like good.
I'm novice in all programation world, help me please to put the information data on your table.
Thanks again.
from bootstrap-table.
Hi @tiagoriba , here you need to set data-side-pagination="server"
.
from bootstrap-table.
I'm trying to get data from mysql , but table isn't receiving anything , here is my code:
index.php :
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Manager</title>
<link href="includes/css/bootstrap.min.css" rel="stylesheet">
<link href="includes/css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="includes/css/bootstrap-table.css">
<script src="includes/js/jquery-2.1.1.min.js"></script>
<script src="includes/js/bootstrap.min.js"></script>
<script src="includes/js/bootstrap-table.js"></script>
<script src="includes/js/bootstrap-table-pt-BR.js"></script>
</head>
<body>
<table data-toggle="table" data-url="your.php" data-cache="false" data-height="299">
<thead>
<tr>
<th data-field="id">Item ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
</body>
</html>
and my your.php
<?php
require ('/functions/classes/database.php');
$db= new Database;
$db->query('Select * from test');
$count= $db->rowCount();
$result= $db->resultset();
$test= array(
'total' => $count,
'rows' => $result,
);
echo json_encode($test);
?>
output your. php :
{"total":3,"rows":[{"id":"1","name":"test0","price":"0"},{"id":"2","name":"test1","price":"1"},{"id":"3","name":"test2","price":"2"}]}
output index = No Results...
from bootstrap-table.
thanks alot for your support, working now 馃憤
from bootstrap-table.
You're welcome, I have updated your comment use Markdown.
from bootstrap-table.
Hi @wenzhixin . Thank you very much for the good work.
I have the same problem of tiagoriba.
No results...
here my "json.php" and the index. Can someone help me ? (I'm sorry, i don't know how to use markdown to mark the code)
json.php
include 'ARQUIVOS/functions/functions.php';
$query = "SELECT setor, nome, ramal FROM contatos ORDER BY setor ASC, nome ASC";
//Faz a conex茫o com o banco de dados e executa a query
$result = db_query($query);
while($r = mysqli_fetch_assoc($result)) {
//$dados[]= $r['idcontatos'];
$dados[]= $r;
}
// free result set
$result->close();
// close connection
mysqli_close($result);
echo json_encode($dados);
And index.php:
<head>
<meta charset="utf-8">
<title>Manager</title>
<link href="ARQUIVOS/css/bootstrap.min.css" rel="stylesheet">
<link href="ARQUIVOS/css/estilo.css" type="text/css" rel="stylesheet" />
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="ARQUIVOS/js/bootstrap.min.js"></script>
<script src="ARQUIVOS/js/bootstrap-table/dist/bootstrap-table.js" type="text/javascript"></script>
<script src="ARQUIVOS/js/bootstrap-table/dist/locale/bootstrap-table-pt-BR.js" type="text/javascript"></script>
</head>
<body>
<table data-toggle="table"
data-url="json.php"
data-cache="false"
data-side-pagination="server"
data-height="300">
<thead>
<tr>
<th data-field="setor">setor</th>
<th data-field="nome" data-align="right">nome</th>
<th data-field="ramal" data-align="center">ramal</th>
</tr>
</thead>
</table>
</body>
from bootstrap-table.
It seems you need to set data-side-pagination="server"
to data-side-pagination="client"
@crynos
from bootstrap-table.
@crynos how would be your functions.php?
from bootstrap-table.
@wenzhixin thanks,get method is ok ,but when i used post,table don't work.i don't konw why,please.
from bootstrap-table.
Related Issues (20)
- Using showSearchClearButton does not clear searchText from options
- Make the clearFilterControl optional when using data-show-search-clear-button
- Error when using localStorage with filter controls and cookies.
- 4 questions HOT 10
- Custom filter is not called for null values HOT 5
- Update version of tableExport.jquery.plugin
- How to insert sparkline graph to cell HOT 1
- Typo in https://bootstrap-table.com/docs/extensions/copy-rows/#copywithhidden
- I would like to be able to use my own print table implementation HOT 2
- Virtual Scroll in Modal HOT 2
- image zoom not appearing above table element HOT 2
- Pagination, Cookie Problem - Last active page not opened after reload HOT 1
- Custom parameters with AddrBar HOT 2
- checkbox checked condition different from it's value field HOT 1
- checkbox data submission when using paginations
- How to use filter-control to search records between two dates HOT 2
- Extension [ToolBar] display error with [i18n-enhance]
- updateColumnTitle use HTML with Toolbar extension display problem
- The cookie extension cannot work with pagination all list
- 'refresh' method doesn't reuse parameters provided as "query", it only takes "url". HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
馃枛 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 馃搳馃搱馃帀
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google 鉂わ笍 Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bootstrap-table.