gpt4 book ai didi

php-mysql : concat query in below code and manipulation of code

转载 作者:行者123 更新时间:2023-11-29 08:22:17 25 4
gpt4 key购买 nike

这是我的代码

<?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);
?>

我的输出是

ID   firstname     lastname  password*
1 john abc
2 don def
3 man ghi

我想要使用 id+名字 来取消密码。请帮助我完成上面的代码...

最佳答案

更正的代码:

<?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);

?>

关于php-mysql : concat query in below code and manipulation of code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19020312/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com