在单独的列上创建php新闻列表
所以我有这个密码在单独的列上创建php新闻列表,php,html,function,zurb-foundation,Php,Html,Function,Zurb Foundation,所以我有这个密码 $news_per_page = 30; $news_per_columns = $news_per_page / 3; $lower_bound = ($current_page * $news_per_page) - $news_per_page + 1; $upper_bound = $current_page * $news_per_page; echo '<div class="large-4 columns">'; echo list_news (
$news_per_page = 30;
$news_per_columns = $news_per_page / 3;
$lower_bound = ($current_page * $news_per_page) - $news_per_page + 1;
$upper_bound = $current_page * $news_per_page;
echo '<div class="large-4 columns">';
echo list_news ($id_category,
$lower_bound,
$upper_bound,
NULL,
( IsSet($_GET['title_subtitle']) && $_GET['title_subtitle'] != "" ? $_GET['title_subtitle'] : NULL ),
( IsSet($_GET['category']) && $_GET['category'] != 0 ? $_GET['category'] : NULL ),
( IsSet($_GET['datefrom_m']) && $_GET['datefrom_m'] != '' && IsSet($_GET['datefrom_d']) && $_GET['datefrom_d'] != '' && IsSet($_GET['datefrom_y']) && $_GET['datefrom_y'] != '' ? strtoupper($_GET['datefrom_m']).' '.$_GET['datefrom_d'].' '.$_GET['datefrom_y'] : NULL),
( IsSet($_GET['dateto_m']) && $_GET['dateto_m'] != '' && IsSet($_GET['dateto_d']) && $_GET['dateto_d'] != '' && IsSet($_GET['dateto_y']) && $_GET['dateto_y'] != '' ? strtoupper($_GET['dateto_m']).' '.$_GET['dateto_d'].' '.$_GET['dateto_y'] : NULL));
echo '</div>';
$news\u每页=30;
$news\u per_columns=$news\u per_page/3;
$lower_bound=($current_page*$news_per_page)-$news_per_page+1;
$upper_bound=$current_page*$news_per_page;
回声';
回声列表新闻($id\u分类,
美元下界,
$上限,
无效的
(IsSet($\u GET['title\u subtitle'])和&$\u GET['title\u subtitle']!=“”?$\u GET['title\u subtitle']:NULL),
(IsSet($\u GET['category'])和&$\u GET['category']!=0?$\u GET['category']:NULL),
(IsSet($获取['datefrom'])和&$获取['datefrom']!=''和IsSet($获取['datefrom'])和&$获取['datefrom']!=''和IsSet($获取['datefrom'y'])和&$获取['datefrom'y']!=''strotupper($获取['datefrom'm'])。$和$$获取['datefrom'空日期].'.$和.$获取[',
(IsSet($获取['dateto_m'])和&$获取['dateto_m']!=''和IsSet($获取['dateto_d'])和&$获取['dateto_d']!=''和&$获取['dateto y']!=''strotupper($获取['dateto m'])。'.$获取['dateto d']。$获取[';
回声';
我的问题是如何使列表新闻功能显示在3列上。目前,该代码显示了30条新闻:<代码>大4< /代码>代码>列>代码>下一个。 < P>网格布局是这样的:
<div class="row">
<div class="large-4 columns"></div>
<div class="large-4 columns"></div>
<div class="large-4 columns"></div>
</div>
<div class="large-4 columns">
<!-- NEWS -->
<!-- NEWS -->
<!-- NEWS -->
</div>
您提供的代码只显示一列,不显示行。如果希望有3列,则需要填充所有三列,并在其周围有一个行容器
<div class="row">
<div class="large-4 columns">News Item 1</div>
<div class="large-4 columns">News Item 2</div>
<div class="large-4 columns">News Item 3</div>
</div>
新闻项目1
新闻项目2
新闻项目3
看不到你的全部代码你可以这样做
echo "<div class='row'><div class='large-4 columns'>";
for( $i = 1; $i < 31; $i++ )
{
print "news";
if( $i == 10 || $i == 20 )
{
echo "</div><div class='large-4 columns'>";
}
}
echo "</div>";
echo”“;
对于($i=1;$i<31;$i++)
{
印刷“新闻”;
如果($i==10 | |$i==20)
{
回声“;
}
}
回声“;
这将在每一列中放置10次“新闻”,然后所有的新闻都将放在一行中。如foundations 6 framework() 这就是网格布局的外观:
<div class="row">
<div class="large-4 columns"><!-- ... --></div>
<div class="large-4 columns"><!-- ... --></div>
<div class="large-4 columns"><!-- ... --></div>
</div>
现在,您的代码打印如下内容:
<div class="row">
<div class="large-4 columns"></div>
<div class="large-4 columns"></div>
<div class="large-4 columns"></div>
</div>
<div class="large-4 columns">
<!-- NEWS -->
<!-- NEWS -->
<!-- NEWS -->
</div>
所以,您需要做的是一个循环,以打印出包含“row”类元素的3个系列的新闻。我已经这样做了,但在页面上达到30篇文章时不会停止。 我开始在3个栏目上显示我的5000多条新闻
$news_per_page = 30;
$news_per_columns = $news_per_page / 3;
$lower_bound = ($current_page * $news_per_page) - $news_per_page + 1;
$upper_bound = $current_page * $news_per_columns;
while($news_per_page <= 30){
echo "<div class='large-4 columns'>";
echo list_news ($id_category,
$lower_bound,
$upper_bound,
NULL,
( IsSet($_GET['title_subtitle']) && $_GET['title_subtitle'] != "" ? $_GET['title_subtitle'] : NULL ),
( IsSet($_GET['category']) && $_GET['category'] != 0 ? $_GET['category'] : NULL ),
( IsSet($_GET['datefrom_m']) && $_GET['datefrom_m'] != '' && IsSet($_GET['datefrom_d']) && $_GET['datefrom_d'] != '' && IsSet($_GET['datefrom_y']) && $_GET['datefrom_y'] != '' ? strtoupper($_GET['datefrom_m']).' '.$_GET['datefrom_d'].' '.$_GET['datefrom_y'] : NULL),
( IsSet($_GET['dateto_m']) && $_GET['dateto_m'] != '' && IsSet($_GET['dateto_d']) && $_GET['dateto_d'] != '' && IsSet($_GET['dateto_y']) && $_GET['dateto_y'] != '' ? strtoupper($_GET['dateto_m']).' '.$_GET['dateto_d'].' '.$_GET['dateto_y'] : NULL));
echo "</div>";
$lower_bound = $lower_bound + $news_per_columns - 1;
$upper_bound = $upper_bound + $news_per_columns;
}
$news\u每页=30;
$news\u per_columns=$news\u per_page/3;
$lower_bound=($current_page*$news_per_page)-$news_per_page+1;
$upper\u bound=$current\u page*$news\u per\u columns;
虽然($news\u每页没有足够的信息给您提供简单的解决方案。'large-4 columns'是否是任何css框架的一部分?是否有其他类似的预定义类可供您使用?'large-4 columns'类的定义是什么?最后,您是否尝试过'large-3 columns'?:Plarge-4 columns是Foundation 6框架的一部分,并且$lower\u bound是。)从witch news id开始,$upperbound是它停止显示的地方。我在另一个文件中有行div,该文件正在行内导入此代码。因此,你知道如何在每个列上显示30条新闻10的同时,或函数在每个列上显示30条新闻10吗?@FarcasAlexandru我已经更新了我的答案,希望它能说明一些问题。然后我很抱歉,但我我不知道你现在想要什么。