0

您好,我在 CMS 的一个模板中有这个排序功能。如果条件是第二个,我想添加:

if(is_array($array)) {
foreach($array as $row) {
    if($row[photos] == 1) { 
        if($isMobile) {
            include($basepath.'/templates/mobile.content_item_photo.php');
        }

        else

         {
            include($basepath.'/templates/template.content_item_photo.php');

        }

我还想添加以下 MySQL 结果以显示

$result = mysql_query("SELECT niches.name, niches.record_num FROM niches ORDER BY name ASC");

在此模板中用于排序:

include($basepath.'/templates/template.channel_item_title.php');  

任何想法如何将其集成到第一个代码函数中?

所以这里是主索引模板的代码:

    <?
session_start();
if(($_REQUEST[mode] == 'favorites' || $_REQUEST[mode] == 'my_uploads') && !$_SESSION[username]) {
    header("Location: /login.php");
}

include('admin/db.php');
include($basepath.'/includes/inc.seo.php');



$cacheName = $_SERVER[REQUEST_URI];

$cacheResult = getCache($cacheName);
$cacheTotalPages = getCache("total_pages$cacheName"); 

if($cacheResult && $cacheTotalPages) {
    $array = $cacheResult;
    $total_pages = $cacheTotalPages;
}
else {
    include($basepath.'/includes/inc.index_queries.php');
    while($row = mysql_fetch_assoc($result)) {
                $array[] = $row;
    }
    if($thispage != 'favorites' && $_GET[mode] != 'my_uploads') {
        setCache($cacheName,$array,$overall_cache_time);
        setCache("total_pages$cacheName",$total_pages,$overall_cache_time);
    }
}

$thisfile = 'index';
$webpage="index";

if($isMobile) {
    include($basepath.'/templates/mobile.overall_header.php');
}
else {
    include($basepath.'/templates/template.overall_header.php');
}

if(empty($_GET[mode]) && !$_GET[page]) { 

    include($basepath.'/templates/template.home.php');

}

if($webpage=="index" && empty($_GET[mode]) && !$_GET[page])

{}

else
{



if(is_array($array)) {
    foreach($array as $row) {
        if($row[photos] == 1) { 
            if($isMobile) {
                include($basepath.'/templates/mobile.content_item_photo.php');
            }

            else                            

             {
                include($basepath.'/templates/template.content_item_photo.php');

            }


        }
        else {
            if($isMobile) {
                include($basepath.'/templates/mobile.content_item.php');
            }
            else 

            {
                include($basepath.'/templates/template.content_item.php');
            }

        }
    }
}


else {
    echo "Sorry, no results were found.";
}
}

if($isMobile) {
    include($basepath.'/templates/mobile.overall_footer.php');
}
else {
    include($basepath.'/templates/template.overall_footer.php');
}
?>
4

1 回答 1

0

我想我没有得到你的问题,但我们必须从某个地方开始......

<?php
if(is_array($array)) {
foreach($array as $row) {
    if($row[photos] == 1) { 
        if($isMobile) {
            include($basepath.'/templates/mobile.content_item_photo.php');
        }

        else

         {

            include($basepath.'/templates/template.content_item_photo.php');

        }

下一个代码块:

<?php
$result = mysql_query("SELECT niches.name, niches.record_num FROM niches ORDER BY name ASC");

if(is_array(result)) {
foreach($result as $row) {
    if($row[photos] == 1) { 
        if($isMobile) {
            include($basepath.'/templates/mobile.content_item_photo.php');
        }

        else

         {

            include($basepath.'/templates/template.channel_item_title.php');

        }
于 2013-03-26T23:05:39.443 回答