[英]php-mysql : concat query in below code and manipulation of code
here is my code 这是我的代码
<?php
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$offset = ($page-1)*$rows;
$result = array();
include 'conn.php';
//$rs1 = "select CONCAT(id,' ',firstname) AS password FROM users";
$rs = mysql_query("select count(*) from users");
$row = mysql_fetch_row($rs);
$result["total"] = $row[0];
$rs = mysql_query("select * from users limit $offset,$rows");
$items = array();
while($row = mysql_fetch_object($rs)){
array_push($items, $row);
}
$result["rows"] = $items;
echo json_encode($result);
?>
and my output is 我的输出是
ID firstname lastname password*
1 john abc
2 don def
3 man ghi
I want password to cancat with id+firstname.. help me in above code please... 我想用id + firstname的密码来cancat ..请帮我以上代码请...
Corrected Code: 更正代码:
<?php
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$offset = ($page-1)*$rows;
$result = array();
include 'conn.php';
//$rs1 = "select CONCAT(id,' ',firstname) AS password FROM users";
$rs = mysql_query("select count(*) from users");
$row = mysql_fetch_row($rs);
$result["total"] = $row[0];
$rs = mysql_query("select *, CONCAT(id, firstname, password) AS pwd from users limit $offset,$rows");
$items = array();
while($row = mysql_fetch_object($rs)){
array_push($items, $row);
}
$result["rows"] = $items;
echo json_encode($result);
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.