鱼C论坛

 找回密码
 立即注册
查看: 2770|回复: 4

HTML5+EaSyUi +php +mysql 仿问数据库显示不出来,求大神帮忙????

[复制链接]
发表于 2021-10-14 17:49:41 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
HTML5+EaSyUi +php +mysql 仿问数据库显示不出来,求大神帮忙????

index.html 中的代码是这样的

  1. <!DOCTYPE html>
  2. <html>

  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title> JSEasy 表格边接数据库</title>
  6.     <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/default/easyui.css">

  7.     <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/icon.css">

  8.     <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/color.css">
  9.     <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/demo/demo.css">

  10.     <script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.min.js"></script>
  11.     <script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
  12. </head>

  13. <body>

  14.     <div id="toolbar">
  15.         <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">添加客户</a>
  16.         <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">修改客户</a>
  17.         <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除</a>
  18.     </div>

  19.     <div id="dlg-buttons">
  20.         <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">提交</a>
  21.         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">取消</a>
  22.     </div>

  23.     <!--  建立表格的表头-->
  24.     <table id="dg" title="客户预览" class="easyui-datagrid" url="get_users.php" style="width:700px;height:250px" toolbar="#toolbar" rownumbers="true" fitColumns="true" singleSelect="true">
  25.         <thead>
  26.             <tr>
  27.                 <th field="firstname" width="50">姓名</th>
  28.                 <th field="lastname" width="50">地址</th>
  29.                 <th field="phone" width="50">联系方式</th>
  30.                 <th field="email" width="50">Email</th>
  31.             </tr>
  32.         </thead>
  33.     </table>




  34.     <div id="dlg" class="easyui-dialog" style="width:400px" data-options="closed:true,modal:true,border:'thin',buttons:'#dlg-buttons'">
  35.         <form id="fm" method="post" novalidate style="margin:0;padding:20px 50px">
  36.             <h3>新建用户</h3>

  37.             <div style="margin-bottom:10px">
  38.                 <input name="firstname" class="easyui-textbox" required="true" label="姓名:" style="width:100%">
  39.             </div>

  40.             <div style="margin-bottom:10px">
  41.                 <input name="lastname" class="easyui-textbox" required="true" label="地址::" style="width:100%">
  42.             </div>

  43.             <div style="margin-bottom:10px">
  44.                 <input name="phone" class="easyui-textbox" required="true" label="联系方式:" style="width:100%">
  45.             </div>

  46.             <div style="margin-bottom:10px">
  47.                 <input name="email" class="easyui-textbox" required="true" validType="email" label="Email:" style="width:100%">
  48.             </div>


  49.         </form>
  50.     </div>



  51.     <script>
  52.         var url;
  53.         // 新建用户
  54.         function newUser() {
  55.             $('#dlg').dialog('open').dialog('center').dialog('setTitle', '新建客户');
  56.             $('#fm').form('clear');
  57.             url = 'save_user.php';
  58.         }
  59.         //修改用户
  60.         function editUser() {
  61.             var row = $('#dg').datagrid('getSelected');
  62.             if (row) {
  63.                 $('#dlg').dialog('open').dialog('center').dialog('setTitle', 'Edit User');
  64.                 $('#fm').form('load', row);
  65.                 url = 'update_user.php?id=' + row.id;
  66.             }
  67.         }
  68.         //保存存用户
  69.         function saveUser() {
  70.             $('#fm').form('submit', {
  71.                 url: "save_user.php",
  72.                 onSubmit: function() {
  73.                     return $(this).form('validate');
  74.                 },
  75.                 success: function(result) {
  76.                     var result = eval('(' + result + ')');
  77.                     if (result.errorMsg) {
  78.                         $.messager.show({
  79.                             title: 'Error',
  80.                             msg: result.errorMsg
  81.                         });
  82.                     } else {
  83.                         $('#dlg').dialog('close'); // close the dialog
  84.                         $('#dg').datagrid('reload'); // reload the user data
  85.                     }
  86.                 }
  87.             });
  88.         }
  89.         //删除用户
  90.         function destroyUser() {
  91.             var row = $('#dg').datagrid('getSelected');
  92.             if (row) {
  93.                 $.messager.confirm('Confirm', 'Are you sure you want to destroy this user?', function(r) {
  94.                     if (r) {
  95.                         $.post('destroy_user.php', {
  96.                             id: row.id
  97.                         }, function(result) {
  98.                             if (result.success) {
  99.                                 $('#dg').datagrid('reload'); // reload the user data
  100.                             } else {
  101.                                 $.messager.show({ // show error message
  102.                                     title: 'Error',
  103.                                     msg: result.errorMsg
  104.                                 });
  105.                             }
  106.                         }, 'json');
  107.                     }
  108.                 });
  109.             }
  110.         }
  111.     </script>

  112. </body>

  113. </html>
复制代码


3.png


PHP 代码是这样的,文件名是:get_users.php

  1. <?php
  2. /*
  3.         $page = isset($_POST['page']) ? intval($_POST['page']) : 1;
  4.         $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
  5.         $offset = ($page-1)*$rows;
  6.         */

  7.         //include 'conn.php';
  8.         $servername = "127.0.0.1";
  9.         $username = "root";
  10.         $password = "12345678";
  11.         // 创建连接
  12.         $conn = new mysqli($servername,$username,$password);
  13.         // 验证连接
  14.         if (!$conn) {
  15.                 die('连接失败!!!' . $conn->connect_error);
  16.         }
  17.         echo "连接成功<br>";
  18.         mysqli_query($conn , "set names utf8");
  19.         $tb_coon = mysqli_select_db($conn,'mydb');
  20.        
  21.         $rs = mysqli_query($conn,"select * from users");
  22.         $result = array();
  23. /*
  24.         $row = mysqli_fetch_row($rs);
  25.         $result["total"] = $row[0];
  26.         $rs = mysqli_query($conn,"select * from users limit $offset,$rows");
  27.         $items = array();

  28.         while($row = mysqli_fetch_object($rs)){
  29.                 array_push($items, $row);
  30.         }
  31.         $result["rows"] = $items;
  32.                 */

  33.         while($row = mysqli_fetch_object($rs)){
  34.                         array_push($result, $row);
  35.                 }

  36.         echo json_encode($result);

  37. /*
  38.         $rs->free();
  39.         $mysql->closedir;
  40.         */
  41. ?>
复制代码


2.png


内容就是不显示出来,找了很多网上,方法都用到了,我把文件都放在同一个目录下。求大神帮忙
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-10-14 19:24:53 From FishC Mobile | 显示全部楼层
查一下前端,看看后台数据是否能传过来
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-10-15 09:12:40 | 显示全部楼层
wp231957 发表于 2021-10-14 19:24
查一下前端,看看后台数据是否能传过来

怎么查?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-15 11:48:24 | 显示全部楼层

这东西  也好查  也不好查    我不咋懂PHP  也没你的数据库   所以基本帮不到你

宗旨就一点,打通前后台通道,确保前端数据  后台能正确接到
                                             确保后台数据  前端能正确接到并渲染

这东西就得自己慢慢查  别无它法   
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-15 11:49:21 | 显示全部楼层

实在不行,可以把你的sql打包后的数据 给我发出来
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-27 11:45

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表