admin管理员组文章数量:1356343
Greetings all.
I have a php script calling MYSQL and displaying data in a table. It is rather ugly and I would rather have it displayed in a Dojo style table/datagrid. Can anyone point me in the right direction?
thanks!
Greetings all.
I have a php script calling MYSQL and displaying data in a table. It is rather ugly and I would rather have it displayed in a Dojo style table/datagrid. Can anyone point me in the right direction?
thanks!
Share Improve this question asked May 22, 2009 at 15:48 JoshJosh3 Answers
Reset to default 7Passing data from MySQL to Dojo DataGrid requires a simple server side ponent. A recent discussion at Dojo forums demonstrates how to format MySQL query results in PHP into a format that Dojo's standard data stores understand:
// do your mysql query and get a result set
$arr = array();
while($row = mysql_fetch_object($result)){
$arr[] = $row;
}
// assuming you're running php version 5.2.x or higher
// this also assumes each row in the array has a identifer field 'id' and a field "name" in the database table which are returned from the mysql query.
$jsonStr = json_encode($arr);
echo "{'identifier':'id','label':'name','items':$jsonStr}";
Check out also this ment about PHP backend for sorting and searching. And this message for yet another PHP backend sample (no grid, though): Bringing PHP, MySQL, and Dojo together.
In addition, Dojo's tests are always a helpful resource. Like this one that demonstrates dispalying and editing data in a mysql database. But note: it's going to work only on your local box and only after you have edited username/password and pointed it to an existing database in sample protocol implementation. Plus, it's for the older Grid-ponent and hasn't been yet ported for the newer DataGrid. However, that file is an excellent starting point as it shows what functions are needed for editing data and how to get started with them.
I don't know Dojo's DataGrid, but here's some simple code I use with ExtJS:
while($row = db_fetch_array($db_result)) $rows[] = $row;
echo json_encode($rows);
http://jslib-test.amplio-vita/JSLib/demos/DBGrid/
本文标签: phpmysql data into Dojo datagrid tableStack Overflow
版权声明:本文标题:php - mysql data into Dojo datagrid table - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744006123a2574731.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论