EasyUI Forum
September 13, 2025, 04:31:06 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: datalist data from mysql  (Read 18832 times)
Szoron
Newbie
*
Posts: 21


View Profile
« on: March 13, 2015, 07:48:32 AM »

Hello!

I was preparing to give a mobile database interface.
How can I spit out a list-data in the returned data from mysql?
Thank you in advance for your help!

Most ez a forráskód:

Code:
<!DOCTYPE html>
<html>

<body>
    <div class="easyui-navpanel" style="position:relative;padding:20px">
        <header>
            <div class="m-toolbar">
              <div>
                  <input class="easyui-datebox" name='d' id='d' prompt="Dátum" data-options="editable:false,panelWidth:220,panelHeight:240,iconWidth:30" style="width:100%">
              </div>
            </div>
        </header>

          <ul class="easyui-datalist" data-options="
                  fit: true,
                  lines: true,
                  url: 'sql_address.php',
                  method: 'get',
                  border: false,
                  textFormatter: function(value){
                      return '<a href\'javascript:void(0)\' class=\'datalist-link\'>' + value + '</a>';
                  },
                  onClickRow: function(index,row){
                      $('#p2-title').html(row.addr);
                      $.mobile.go('#p2');
                  }
                  ">

          </ul>

    </div>
    <style scoped>
        form label{
            display: block;
            margin: 10px 0 5px 0;
        }
    </style>
</body>
</html>

Code:
<?php
include 'conn.php';
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET utf8 ");
//$act_date = mysql_real_escape_string($_REQUEST['d']);
$act_date $_POST['d'];
$query "SELECT address.efi_address AS name, work_types.name AS n, address.ml_num AS ml FROM walker4.address";
$query .= "LEFT JOIN tchs ON tchs.id = address.tch";
$query .= "LEFT JOIN work_types ON work_types.id = address.work_type";
//$query .= "WHERE address.works_date =";
//$query .= $act_date;
$rs mysql_query($query);
$items = array();
while(
$row mysql_fetch_object($rs)){
  
array_push($items$row);
}
$result["rows"] = $items;
echo 
json_encode($result);

?>
« Last Edit: March 13, 2015, 12:39:08 PM by Szoron » Logged
Szoron
Newbie
*
Posts: 21


View Profile
« Reply #1 on: March 13, 2015, 12:38:12 PM »

Upgraded code:!

but no result
It does not return any results

Code:
<!DOCTYPE html>
<html>

<body>
    <div class="easyui-navpanel" style="position:relative;padding:20px">
        <header>
            <div class="m-toolbar">
              <div>
                  <input class="easyui-datebox" name='d' id='d' prompt="Dátum" data-options="editable:false,panelWidth:220,panelHeight:240,iconWidth:30" style="width:100%">
              </div>
            </div>
        </header>

          <ul class="easyui-datalist" data-options="
                  fit: true,
                  lines: true,
                  url: 'sql_address.php',
                  method: 'get',
                  valueField: 'id',
                  textField: 'name'
                  ">
          </ul>
    </div>
    <style scoped>
        form label{
            display: block;
            margin: 10px 0 5px 0;
        }
    </style>
</body>
</html>

Code:
<?php
include 'conn.php';
//$rs = mysql_query("SELECT address.efi_address AS name, work_types.name AS n, address.ml_num AS ml FROM walker4.address LEFT JOIN tchs ON tchs.id = address.tch LEFT JOIN work_types ON work_types.id = address.work_type");
$rs mysql_query("SELECT id, name, status FROM close_codes");
$result = array();
$items = array();
while(
$row mysql_fetch_object($rs)){
  
array_push($items$row);
}
$result["total"] = 5;
$result["rows"] = $items;
echo 
json_encode($result);
?>
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: March 13, 2015, 07:00:07 PM »

Please check your 'sql_address.php' carefully on the browser to determine if there are some errors occur.
Logged
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« Reply #3 on: March 14, 2015, 09:34:09 AM »

Just use echo json_encode($items);
instead of writing following three lines.

$result["total"] = 5;
$result["rows"] = $items;
echo json_encode ($result);
Logged
Szoron
Newbie
*
Posts: 21


View Profile
« Reply #4 on: March 15, 2015, 11:14:30 PM »

Thanks  for help
Success
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!