Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在页面内显示存档(下拉)和类别(下拉)_Php_Templates_Drop Down Menu_Archive - Fatal编程技术网

Php 在页面内显示存档(下拉)和类别(下拉)

Php 在页面内显示存档(下拉)和类别(下拉),php,templates,drop-down-menu,archive,Php,Templates,Drop Down Menu,Archive,我有一个问题: 我有一个存档模板页面,在那里我想显示两个下拉菜单:存档和类别下拉菜单,当我点击时,例如11月份的存档,因此所有项目将从11月份起显示在侧面,并且它也可以工作。。。但是,如果选择菜单项,则将显示所有项目,而不仅仅是此类别的文章 代码如下: 在archives.php中有以下代码(我认为这里的代码都是正确的): 月 &mdash; 类别 在另一个名为Archives-getter.php的模板中,出现了以下代码,其中有一个错误: <?php /* T

我有一个问题:

我有一个存档模板页面,在那里我想显示两个下拉菜单:存档和类别下拉菜单,当我点击时,例如11月份的存档,因此所有项目将从11月份起显示在侧面,并且它也可以工作。。。但是,如果选择菜单项,则将显示所有项目,而不仅仅是此类别的文章

代码如下:

在archives.php中有以下代码(我认为这里的代码都是正确的):


月
&mdash;
类别
在另一个名为Archives-getter.php的模板中,出现了以下代码,其中有一个错误:

<?php
    /*
        Template Name: Archives Getter
    */
    $year = htmlspecialchars(trim($_POST));
    $month = htmlspecialchars(trim($_POST));
    $cat = htmlspecialchars(trim($_POST));
    $querystring = "year=$year&monthnum=$month&cat=$cat&posts_per_page=-1";
    query_posts($querystring); 
?>
<?php if (($year == '') && ($month == '') && ($cat == '-1')) { ?>
    <table id="archives-table"><tr><td style='text-align: center; font-size: 15px; padding: 5px;'>Please choose from above.</td></tr></table>
<?php } else { ?>
    <table id="archives-table">
        <?php    
            if (have_posts()) : while (have_posts()) : the_post(); ?>
                <tr>
                    <td><img src="<?php echo get_post_meta($post->ID, 'PostThumb', true); ?>" alt="" style="width: 35px;" /></td>
                    <td><a href='<?php the_permalink(); ?>'><?php the_title(); ?></a></td>
                    <td><?php comments_popup_link(' ', '1 Comment', '% Comments'); ?></td>
                    <td><?php the_date('m/j/Y'); ?></td>
                </tr>
        <?php 
            endwhile; else:
                echo "<tr><td style='text-align: center; font-size: 15px; padding: 5px;'>Nothing found.</td></tr>";
            endif; 
        ?>
    </table>
<?php } ?>

请从上面选择。
ID,“PostThumb”,true);?>“alt=”“style=”宽度:35px;" />

您需要在此处指定post字段名称:

$year = htmlspecialchars(trim($_POST));
$month = htmlspecialchars(trim($_POST));
$cat = htmlspecialchars(trim($_POST));
应该是这样的(名称取决于表单字段

$year = htmlspecialchars(trim($_POST['year_y']));
$month = htmlspecialchars(trim($_POST['month_m']));
$cat = htmlspecialchars(trim($_POST['cat_c']));
此类表单输入应具有以下名称:

<select id="month-choice">

像这样

<select id="month-choice" name="month">


你应该编辑你的问题或添加评论。当它不是答案时,不要将其作为答案添加。除此之外,我没有更正下拉列表,我更正了进入帖子查询的值,这是显示你所说的不起作用的帖子的部分。我将编辑我的答案,以包含你在此处提到的新帖子名称你好,对不起我点击了回复…所以我现在真的尝试了这里所有可能的组合“示例4“,但不幸的是,它仍然没有下拉菜单…它只是不会按类别或当月类别显示这些产品的项目XY XY…我还不知道该做什么…有人有想法或可以测试脚本。感谢您的回答。”。
<select id="month-choice">
<select id="month-choice" name="month">