小编sha*_*ebp的帖子

php mysql Group By获取最新记录,而不是第一条记录

桌子:

(`post_id`, `forum_id`, `topic_id`, `post_time`) 
(79, 8, 4, '2012-11-19 06:58:08');
(80, 3, 3, '2012-11-19 06:58:42'),
(81, 9, 9, '2012-11-19 06:59:04'),
(82, 11, 6, '2012-11-19 16:05:39'),
(83, 9, 9, '2012-11-19 16:07:46'),
(84, 9, 11, '2012-11-19 16:09:33'),
Run Code Online (Sandbox Code Playgroud)

查询:

SELECT  post_id, forum_id, topic_id FROM posts 
GROUP BY topic_id 
ORDER BY post_time DESC
LIMIT 5
Run Code Online (Sandbox Code Playgroud)

结果:

[0] => [post_id] => 84 [forum_id] => 9 [topic_id] => 11  
[1] => [post_id] => 82 [forum_id] => 11 [topic_id] => 6  
[2] => [post_id] => 81 [forum_id] …
Run Code Online (Sandbox Code Playgroud)

php mysql

16
推荐指数
2
解决办法
3万
查看次数

Wordpress Ajax Firefox没有响应

我正在Wordpress / Buddypress中尝试简单的Ajax测试。

下面的代码在IE和Chrome中可以正常运行。但是在Firefox中,会调用javascript,但随后它只会刷新当前页面。在Firebug控制台中没有错误,但响应为空。我不认为该PHP被称为。

要在Firefox中正常运行,我需要更改什么?

javascript:

jQuery(document).ready(function(){

    jQuery('#test-form input#save').click(function(){
            jQuery('.ajax-loader').toggle();

            jQuery('#save').attr({'disabled': true});

            jQuery.post( ajaxurl, {
                    action: 'test_save',
                    'cookie': encodeURIComponent(document.cookie),
                    '_wpnonce': jQuery("input#_wpnonce-save").val(),
            },
                    function(response) {              
                            jQuery('.ajax-loader').toggle();
            // alerts work up to here in all browsers
                            jQuery('#test-form').append(response);
                    });
            });
Run Code Online (Sandbox Code Playgroud)

});

的PHP:

add_action( 'bp_after_profile_loop_content', 'show_test', 100 );    
add_action('wp_ajax_test_save', 'test_save_function');

function show_test() { 
?>
<form action="#" id="test-form">
    <?php wp_nonce_field( 'save', '_wpnonce-save' ); ?>  
    <input type="submit" name="save" id="save" value = "test ajax"/>
    <span class="ajax-loader"></span> 
</form>

<?php
}

function test_save_function() {
check_ajax_referer('save');
echo "php -button was …
Run Code Online (Sandbox Code Playgroud)

ajax wordpress firefox

2
推荐指数
1
解决办法
1972
查看次数

标签 统计

ajax ×1

firefox ×1

mysql ×1

php ×1

wordpress ×1