首页 \ 问答 \ while循环只显示1个结果(While loop only showing 1 result)

while循环只显示1个结果(While loop only showing 1 result)

我有一个脚本,用于检查数据库中的dupe值,并循环查看结果并使用json回应该值。 但是,它只显示1条记录,而不是3条发送到php。 如果有人能指出我的错误,我将不胜感激。 谢谢

$boxitems = mysqli_real_escape_string($conn, $_POST['box']);
$array = array();
$array = $boxitems;

foreach ($array as $boxes) {

    $sql = "SELECT item FROM act WHERE item = '".$boxes."' GROUP BY item HAVING COUNT(*) > 1";
    $result = mysqli_query($conn, $sql) or die('Error selecting item: ' . mysqli_error());
    $num_rows = mysqli_num_rows($result);
      if($num_rows) {
        while ($row = mysqli_fetch_array($result)) {
              $data[] =  $row['item'];
          }
          echo '<div style="width: 50%; margin-bottom: 20px; border-radius: 5px; border: 1px solid black; background: red; font-size: 16px; color: white; height: 50px; padding: 15px; line-height: 1.3;">';
          echo json_encode($data)  . ' already exists. Please enter a unique box reference.';
          echo '</div>';
          exit;
        } else {
          echo '<div style="width: 50%; margin-bottom: 20px; border-radius: 5px; border: 1px solid black; background: #63c84c; font-size: 16px; color: white; height: 50px; padding: 15px; line-height: 1.3;">';
          echo 'No dupes found in database.';
          echo '</div>';
          exit;
        }
    }

在这里输入图像描述

更新的屏幕截图

在这里输入图像描述


I have a script that checks for dupe values in db and loops through the result and echoes the value using json. However, it is only displaying 1 record instead of 3 which is being sent to php. I would be grateful if someone could point out my error. Thanks

$boxitems = mysqli_real_escape_string($conn, $_POST['box']);
$array = array();
$array = $boxitems;

foreach ($array as $boxes) {

    $sql = "SELECT item FROM act WHERE item = '".$boxes."' GROUP BY item HAVING COUNT(*) > 1";
    $result = mysqli_query($conn, $sql) or die('Error selecting item: ' . mysqli_error());
    $num_rows = mysqli_num_rows($result);
      if($num_rows) {
        while ($row = mysqli_fetch_array($result)) {
              $data[] =  $row['item'];
          }
          echo '<div style="width: 50%; margin-bottom: 20px; border-radius: 5px; border: 1px solid black; background: red; font-size: 16px; color: white; height: 50px; padding: 15px; line-height: 1.3;">';
          echo json_encode($data)  . ' already exists. Please enter a unique box reference.';
          echo '</div>';
          exit;
        } else {
          echo '<div style="width: 50%; margin-bottom: 20px; border-radius: 5px; border: 1px solid black; background: #63c84c; font-size: 16px; color: white; height: 50px; padding: 15px; line-height: 1.3;">';
          echo 'No dupes found in database.';
          echo '</div>';
          exit;
        }
    }

enter image description here

UPDATED screen shot

enter image description here


原文:https://stackoverflow.com/questions/49189269
更新时间:2021-11-27 12:11

最满意答案

我想到了。 这些文件是作为匿名用户上传的,因此我无法编辑任何关于它们的内容。 我使用正确的凭据重新上传了所有内容,并且能够更改元数据。


I figured it out. The files were uploaded as an anonymous user, therefor I could not edit anything about them. I re-uploaded everything with correct credentials and was able to change the metadata.

相关问答

更多
  • 看起来您需要用自己覆盖对象,除了元数据之外,还使用带有x-amz-metadata-directive: REPLACE标头的“PUT Object(Copy)”。 在博托,这可以这样做: k = k.copy(k.bucket.name, k.name, {'myKey':'myValue'}, preserve_acl=True) 请注意,旧字典中不包含的任何元数据将被删除。 因此,为了保留旧的属性,您需要执行以下操作: k.metadata.update({'myKey':'myValue'}) k ...
  • 如果有任何文件正在上传与多部分,那么你总是会得到这种类型的ETag。 但是,如果您将整个文件上传为单个文件,那么您将像以前一样获得ETag。 桶资源管理器提供正常的ETag,直到5Gb上传多部分操作。 但更多的是它不提供。 https://forums.aws.amazon.com/thread.jspa?messageID=203510#203510 If any file is being uploaded with multipart then you will always get such typ ...
  • 我想到了。 这些文件是作为匿名用户上传的,因此我无法编辑任何关于它们的内容。 我使用正确的凭据重新上传了所有内容,并且能够更改元数据。 I figured it out. The files were uploaded as an anonymous user, therefor I could not edit anything about them. I re-uploaded everything with correct credentials and was able to change the ...
  • “头部”操作将允许您访问元数据而无需获取整个对象。 点击此链接了解更多信息。 如果我是你,我会将元数据存储在DynamoDB中。 玩起来更容易,并且使您的应用程序在未来更加灵活。 A "head" operation will allow you to access the metadata without fetching the entire object. Follow this link for more info. If I were you I would store the metadata ...
  • 尽管S3本身并没有真正的重命名功能,但一些接口可能会尝试并通过在后台使用S3 PUT对象复制和DELETE操作来实现它。 他们的实施可能需要其他存储桶级权限才能完成,这就是为什么它可能与您的策略失败。 尝试这个: { "Sid": "Stmt1490288788", "Effect": "Allow", "Action": [ "s3:*" ], "Resource": [ "arn:aws:s3:::bucket-name", ...
  • 如果您不介意每天仅获取一次信息,则可以使用Amazon S3清单 : Amazon S3清单提供逗号分隔值(CSV)或Apache优化行列(ORC)输出文件,该文件每天或每周为S3存储桶或共享前缀列出您的对象及其对应的元数据 (即,以一个普通字符串开头的名称)。 如果您需要更频繁地更新信息,则可以在存储桶上配置一个事件,以在创建新对象时触发AWS Lambda函数 。 Lambda函数然后可以将这些信息存储在数据库中以备将来参考。 当然,你必须自己编写这些代码。 If you don't mind only ...
  • 文件提到 在URI中引用目标容器(aka bucket)名称,如s3://bucketname/key 。 这意味着区域特定主机名s3-.amazonaws.com可以省略。 The documentation mentions to reference the target container (aka bucket) name in the URI like s3://bucketname/key. This means the region specific hostname s3-< ...
  • 我在v3 AWS SDK for PHP中遇到了同样的问题。 经过一些研究和测试,我确定我可以使用headObject : headObject(array( "Bucket" => $bucket, "Key" => $key )); print_r($headers->toArray()); ?> 使用系统定义的元数据和其他识别信息的示例输出REMOVED: Array ( /* REMOVED */ ...
  • 亚马逊将etag用于系统中的各种任务。 您将不得不继续使用您在问题中提出的元数据。 ETag的 实体标签是对象的哈希。 ETag仅反映对象内容的更改,而不反映其元数据。 ETag可能是也可能不是对象数据的MD5摘要。 是否取决于对象的创建方式和加密方式,如下所述: 由PUT对象,POST对象或复制操作或通过AWS管理控制台创建并由SSE-S3或纯文本加密的对象具有ETag,这些ETag是其对象数据的MD5摘要 。 由PUT对象,POST对象或复制操作或通过AWS管理控制台创建并由SSE-C或SSE-KMS加 ...
  • 由于Firebase存储基于Google云端存储,您可以随时直接访问Google云端存储控制台( console.cloud.google.com/storage )并编辑各个对象的元数据。 Since Firebase Storage is built on Google Cloud Storage, you can always go directly to the Google Cloud Storage console (console.cloud.google.com/storage) and e ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。