如何交换返回集中的行?(How to swap rows in a return set?)
在没有排序顺序列的表中,如何更改结果的顺序?
一个简单的示例表是:
id | content 1 | Some content here 2 | A page describing something 3 | Row 3 Content ... 7 | Some more content 8 | Row 8 Content 9 | An about-us page
执行简单的选择(
SELECT * FROM table
)将以默认顺序返回上述内容。我现在要做的是更改结果,以便将id为3的行替换为id为8的行。
所以期望的输出是:
id | content 1 | Some content here 2 | A page describing something 8 | Row 8 Content ... 7 | Some more content 3 | Row 3 Content 9 | An about-us page
如何扩展我的选择查询以显示我想要的输出?
In a table without a sort-order column how do I change the order of the results?
A simple example table is:
id | content 1 | Some content here 2 | A page describing something 3 | Row 3 Content ... 7 | Some more content 8 | Row 8 Content 9 | An about-us page
Doing a simple select (
SELECT * FROM table
) will return the above in default order.What I want to do now is change the results so that the row with id 3 is replaced with the row with the id of 8.
So the desired output is:
id | content 1 | Some content here 2 | A page describing something 8 | Row 8 Content ... 7 | Some more content 3 | Row 3 Content 9 | An about-us page
How do I extend my select query to show my desired output?
原文:https://stackoverflow.com/questions/33899516
满意答案
如果没有get_field中的第二个参数,您需要处于循环中,而且似乎您不在。
如果您的代码位于页面顶部,则需要添加post ID参数,您需要使用
global $post;
为拿到它,为实现它。<?php global $post; $forside_slagord_stor = get_field('forside_slagord_stor', $post->ID); $forside_slagord_liten = get_field('forside_slagord_liten', $post->ID); $forside_slagord_liter = get_field('om_oss_tekst', $post->ID); ?> <header> <div class="container"> <div class="intro-text"> <div class="intro-lead-in"><?php echo $forside_slagord_stor;?></div> <div class="intro-heading"><?php echo $forside_slagord_liter;?></div> <a href="#services" class="page-scroll btn btn-xl">Tell Me More</a> </div> </div>
关于你的一条评论的另一个答案:你不需要包含任何acf文件,当模板即将渲染时,所有插件文件和资产通常都会加载。
希望能帮助到你!
Without the second parameter in get_field, you need to be in the loop, and it's seems that you are not in.
If your code is at the top of the page, you need to add the post ID parameter, you need to use the
global $post;
to get it.<?php global $post; $forside_slagord_stor = get_field('forside_slagord_stor', $post->ID); $forside_slagord_liten = get_field('forside_slagord_liten', $post->ID); $forside_slagord_liter = get_field('om_oss_tekst', $post->ID); ?> <header> <div class="container"> <div class="intro-text"> <div class="intro-lead-in"><?php echo $forside_slagord_stor;?></div> <div class="intro-heading"><?php echo $forside_slagord_liter;?></div> <a href="#services" class="page-scroll btn btn-xl">Tell Me More</a> </div> </div>
Another answer about one of your comment : you don't need to include any file of acf, when the template is about to render, all the plugins files and assets are usually load.
Hope it helps!
相关问答
更多着色ACF ggplot对象(Coloring ACF ggplot Object)
获取该值后的Wordpress ACF字段更新(Wordpress ACF field update after getting the value)
如果ACF中继器子字段空白,如何隐藏(How to hide if ACF Repeater Sub_field Blank)
ACF Post Object返回false(ACF Post Object returns false)
Javascript getField返回0表示短划线/减号(Javascript getField returns 0 for a dash/minus symbol)
.getField()返回空结果(.getField() returning empty result)
WordPress的:获取ACF子页面选项(Wordpress: Get ACF sub page options)
FileMaker PHP API - getField()不返回所有值(FileMaker PHP API - getField() not returning all values)
ACF - getfield()返回空值(ACF - getfield() returns blank value)
在一个图中绘制几个时间序列的acf(plot acf of several timeseries in one plot)
相关文章
更多Solr: a custom Search RequestHandler
Becoming a data scientist
redis 字符串(String) SET 操作
7月最新发布11.2.0.1.2 Patch set update
How to set up Solr on Ubuntu 10.04 (or whatever)
Python内建函数(A)
[Hadoop] Error: JAVA_HOME is not set
[转]So You Want To Be A Producer
最新问答
更多获取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))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!