首页 \ 问答 \ 循环中将所有项添加到特定条件(Add all items to a specific condition in loop)

循环中将所有项添加到特定条件(Add all items to a specific condition in loop)

当$ date匹配条件时,我希望今天在标题下显示$ date的所有游戏,但是此时我的代码正在循环并为每个条件创建一个新标题,其中$ date = today,如图所示。 今天应该只有一个标题,然后跳到第二天等

在此处输入图像描述

while($row>$played){
            if($row['event_date']== $date){
            echo'<td>TODAY,'.$date.'</td>';
            :
            :
             }

When $date matches criteria I want all games for $date displayed under heading today, however at the moment my code is looping and making a new heading for each criteria where $date = today as you can see in image. There should only be one heading, for today and then skip on to next day etc

enter image description here

while($row>$played){
            if($row['event_date']== $date){
            echo'<td>TODAY,'.$date.'</td>';
            :
            :
             }

原文:
更新时间:2022-03-11 12:03

最满意答案

根据目前的实施方式,它将继续运行。 您需要在connected属性中重复该条件。

<ui:fragment rendered="#{aContent.rendered}">
     <o:socket ... connected="#{aContent.rendered}" />

当我计划为<o:socket>添加<f:ajax>支持时,这可能会在以后改进。

另一方面,您的代码段是非DRY 。 尝试限制只有1个socket + commandScript组合,它根据推送消息的内容动态地完成其工作。 另请参见文档的“ 通道设计提示”部分。


Based on how it's currently implemented, it'll keep running. You need to repeat the condition in the connected attribute.

<ui:fragment rendered="#{aContent.rendered}">
     <o:socket ... connected="#{aContent.rendered}" />

Perhaps this will be improved later when I plan to add <f:ajax> support for <o:socket>.

On the other hand, your code snippet is non-DRY. Try restricting to only 1 socket+commandScript combination which does its job dynamically based on contents of the pushed message. See also Channel design hints section of the documentation.

相关问答

更多
  • 不是现在的样子。 目前它只充当服务器。 您可以做的是使用Play本身的jetty websocket等客户端,然后根据需要处理数据。 Not as it stands. Currently it only acts as a server. What you could do is use a client like jetty websocket from Play itself, and then process the data as you see fit.
  • 在WebSocket连接上,您不需要101 Switching Protocols状态响应。 获得200状态响应可能意味着请求未到达WebSocket Handler。 我还会查看dev-tools,并检查响应是否有任何WebSocket握手头。 如果有,我会认为这是模块的问题。 否则它可能是你的配置。 On a WebSocket connection you want a 101 Switching Protocols status response. Getting a 200 status resp ...
  • WebSocket确实由两个独立的流组成,只是那些流(可能)不在同一个JVM上。 您有两个对等通信,一个是服务器,另一个是客户端,但从已建立的WebSocket连接的角度来看,差异无关紧要。 一个数据流是对等体1向对等体2发送消息,另一个流体是对等体2向对等体1发送消息,然后在这两个对等体之间存在网络边界。 如果您一次查看一个对等体,则对等体1从对等体2接收消息,而在第二流体对等体1中向对等体2发送消息。 每个对等体都有一个接收部分的接收器和一个发送部分的源。 实际上你确实有两个Source和两个Sinks ...
  • 我似乎找到了解决自己问题的方法。 客户端上的示例代码使用channel.write()方法,该方法似乎不会将消息发送到Websocket ssl服务器。 通过使用channel.writeAndFlush()代替,消息被正确发送到服务器。 I seem to have found a solution to my own question. The sample code on the client uses the channel.write() method, which seems not to se ...
  • 我想你想做这样的事情,但我还没有完全理解你想要完成的事情。 您能否以不同的方式添加评论? Map data; void main() { //(querySelector('[name="push"]') as ButtonInputElement).onClick.listen(btnClickHandler); (querySelector('[name="push"]') as ButtonInputElement).onClick.first.then(btnClickHandler); ...
  • 已发布Safari(桌面和移动)使用的hixie-76协议变体和Chrome等使用的RFC 6455的标准 。 您可以使用所请求的握手类型来决定客户端说话的协议版本,消息读取中将存在哪些框架以及在消息写入时应使用哪种框架。 There are published standards for both the hixie-76 protocol variant used by Safari (desktop & mobile) and RFC 6455 used by Chrome and others. Y ...
  • 这样做的问题是,在加载页面之前,您不知道缓存中的内容,这意味着您需要执行另一个 HTTP请求来获取您需要的数据,这会导致更多的开销。 我肯定会坚持使用服务器端的资源缓存。 你可以这样做,但是这样的事情基本上会涉及一个Javascript的主索引页面,它加载了缓存的本地文件或执行了Ajax请求以从服务器加载内容。 The problem with this is that you don't know what's in the cache until you've loaded your page, mea ...
  • f:websocket从JSF 2.3开始可用,虽然Wildfly 12包含一些 JavaEE 8功能,但它默认以JavaEE 7模式启动,它只是'JSF 2.2'。 从最近的WildFly 12发布文档开始 默认情况下,WildFly 12以EE7模式启动。 要使用这些新功能,您必须启用EE8预览模式。 这可以通过在启动期间传递ee8.preview.mode属性来完成: ./standalone.sh -Dee8.preview.mode=true 还有其他选项可以启用此功能。 来自相同的文档: 或者, ...
  • INVALID_STATE_ERR:DOM异常11表示您的websocket尚未处于就绪状态。 你可以通过socket.readyState来检查websocket对象的状态,你可以在socket.readyState == 1时发送消息 我通过使用超时为此创建了一个转变 timerId = setInterval(sendDataWhenReady, 1000); function sendDataWhenReady(){ if(socket.readyState == 1){ ws.send ...
  • 根据目前的实施方式,它将继续运行。 您需要在connected属性中重复该条件。 当我计划为添加支持时,这可能会在以后改进。 另一方面,您的代码段是非DRY 。 尝试限制只有1个socket + commandScript组合,它根据推送消息的内容动态地完成其工作。 另请 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)