我想将for循环的结果作为数组存储在变量中
$res
。我该怎么办?
<?php
$servername = "localhost";
$username = "root";
$password = "";
$name = "abc";
$con = new mysqli ($servername, $username, $password, $name);
$sql1 = $con->query("SELECT (status) FROM `seita`");
$i = $sql1->num_rows;
echo $i;
for($x=1; $x<=$i; $x++)
{
echo $x;
$sql = $con->query("SELECT status FROM `seita` WHERE RollNo = '$x'");
$res = mysqli_fetch_row($sql);
}
?>
Rohit Mittal给出的答案使我无法进行字符串转换。接下来我该怎么办?
答案 0 :(得分:0)
您可以使用fetch_all()
的mysqli在一个查询中获取所有内容
$servername = "localhost";
$username = "root";
$password = "";
$name = "abc";
$con = new mysqli ($servername, $username, $password, $name);
$result = $con->query("SELECT status FROM `seita`")->fetch_all();
答案 1 :(得分:-1)
您可以尝试全部一行完成所有操作。也许与此类似:
$res = $con->query("SELECT status
FROM `seita`
WHERE RollNo between 1 and (
SELECT count(status)
FROM `seita`
)
")->fetch_all();
答案 2 :(得分:-2)
您需要制作一个数组,并且只需要获取以下状态值:
def evaluate_compliance():
sns_client = boto3.client('sns')
response = sns_client.list_topics()
topics = [topic['TopicArn'] for topic in response['Topics']]
for topic_dict in topics:
response = sns_client.list_topics()
response_topic_attributes_dict = sns_client.get_topic_attributes(TopicArn=topic_dict['TopicArn'])
答案 3 :(得分:-2)
您要附加到数组搜索Google func configureCellFromSwiftUIView(cell: UITableViewCell, rootView: AnyView){
let swiftUICellViewController = UIHostingController(rootView: rootView)
cell.layoutIfNeeded()
cell.selectionStyle = UITableViewCell.SelectionStyle.none
self.addChild(swiftUICellViewController)
cell.contentView.addSubview(swiftUICellViewController.view)
swiftUICellViewController.view.translatesAutoresizingMaskIntoConstraints = false
cell.contentView.addConstraint(NSLayoutConstraint(item: swiftUICellViewController.view!, attribute: NSLayoutConstraint.Attribute.leading, relatedBy: NSLayoutConstraint.Relation.equal, toItem: cell.contentView, attribute: NSLayoutConstraint.Attribute.leading, multiplier: 1.0, constant: 0.0))
cell.contentView.addConstraint(NSLayoutConstraint(item: swiftUICellViewController.view!, attribute: NSLayoutConstraint.Attribute.trailing, relatedBy: NSLayoutConstraint.Relation.equal, toItem: cell.contentView, attribute: NSLayoutConstraint.Attribute.trailing, multiplier: 1.0, constant: 0.0))
cell.contentView.addConstraint(NSLayoutConstraint(item: swiftUICellViewController.view!, attribute: NSLayoutConstraint.Attribute.top, relatedBy: NSLayoutConstraint.Relation.equal, toItem: cell.contentView, attribute: NSLayoutConstraint.Attribute.top, multiplier: 1.0, constant: 0.0))
cell.contentView.addConstraint(NSLayoutConstraint(item: swiftUICellViewController.view!, attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, toItem: cell.contentView, attribute: NSLayoutConstraint.Attribute.bottom, multiplier: 1.0, constant: 0.0))
swiftUICellViewController.didMove(toParent: self)
swiftUICellViewController.view.layoutIfNeeded()
中,该搜索给出php array append
array_push($stack, "apple", "raspberry");