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; } }
UPDATED screen shot
原文:https://stackoverflow.com/questions/49189269
最满意答案
我想到了。 这些文件是作为匿名用户上传的,因此我无法编辑任何关于它们的内容。 我使用正确的凭据重新上传了所有内容,并且能够更改元数据。
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 */ ...
-
AWS S3指定etag值(AWS S3 specify etag value)[2023-11-22]
亚马逊将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 ...