gpt4 book ai didi

PHP - While 和包装 div

转载 作者:搜寻专家 更新时间:2023-10-31 21:49:16 24 4
gpt4 key购买 nike

我需要在一天内包装日期和所有事件以划分“obal_date”,但这不起作用。事件的数量可能不同,但我需要包装日期 + 所有事件。请问我该怎么做。非常感谢你。

<?php

# This will hold what group we're in
$current_header = '';

# The Loop
while ( $the_query->have_posts() ) :
$the_query->the_post();

$temp_date = get_post_meta( get_the_ID(), 'datum_eventu', true );

echo '<div class="obal_over">';

if ( $temp_date != $current_header ) {
$current_header = $temp_date;
/*****************output date******************/
?>

<div class="obal_date">

<?php
echo "<span class='date'>".date("d", strtotime($current_header))."</span>";
echo "<span class='month'>".date("M", strtotime($current_header))."</span>";
?>

</div>
<?php
/*****************date end******************/
}
/*****************All event action1, action2....******************/
$title = get_post_meta( get_the_ID(), 'nazev_eventu', true );
$cas = get_post_meta( get_the_ID(), 'cas_eventu', true );

echo '<div class="obal_single">';
echo "<span class='cas'>".$cas."</span>";
echo "<span class='title'>".$title."</span>";
echo '</div>';
echo '</div>';
/*****************End event action1, action2....******************/
endwhile;

?>

编辑1:

我需要得到:

div -> date -> action1 -> action2 -> /div

<div class="obal_over">
<div class="obal_date">
01Sep
</div>
<div class="obal_single">City1 title</div>
<div class="obal_single">City1 title2</div>
<div class="obal_single">City3 title</div>
</div>
//..... other date and action again start class="obal_over"

但是我明白了

div -> date -> action -> /div -> div -> action2 -> /div

<div class="obal_over">
<div class="obal_date">
01Sep
</div>
<div class="obal_single">City1 title</div>
</div>
<div class="obal_over">
<div class="obal_single">City1 title2</div>
</div>
<div class="obal_over">
<div class="obal_single">City3 title</div>
</div>

Previous question

最佳答案

为了方便您列出日期和城市名称的方式,我在 while 循环外添加了一个 div 标签。然后在检查日期相同或不同的 if 条件中使用 obal_over 类(以及结束 div 标记)启动 div。还在 while 循环外添加了结束 div 标记,以提供正确的打开和关闭 div 标记。我认为这会起作用。我无法测试...

    <?php

# This will hold what group we're in
$current_header = '';
echo '<div>';
# The Loop
while ( $the_query->have_posts() ) :
$the_query->the_post();

$temp_date = get_post_meta( get_the_ID(), 'datum_eventu', true );

if ( $temp_date != $current_header ) {
$current_header = $temp_date;
echo '</div>';
echo '<div class="obal_over">';
/*****************output date******************/
?>
<div class="obal_date">

<?php
echo "<span class='date'>".date("d", strtotime($current_header))."</span>";
echo "<span class='month'>".date("M", strtotime($current_header))."</span>";
?>

</div>
<?php
/*****************date end******************/
}
/*****************All event action1, action2....******************/
$title = get_post_meta( get_the_ID(), 'nazev_eventu', true );
$cas = get_post_meta( get_the_ID(), 'cas_eventu', true );

echo '<div class="obal_single">';
echo "<span class='cas'>".$cas."</span>";
echo "<span class='title'>".$title."</span>";
echo '</div>';

/*****************End event action1, action2....******************/



endwhile;
echo '</div>';
?>

关于PHP - While 和包装 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47049762/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com