Support » Fixing WordPress » If/Then, Simple I know.. Please help

  • I have probably the most simple PHP question on this forum. I have two <form> tags in my comments.php, one AJAXed and one traditional (Reason being the very first comment doesn’t work right, so I just want to use the standard form for the first comment on each post and then AJAXed for every additional comment). The code is simple:

    <?php $numbcomments = comments_number('0', '1', '2'); ?>
    <?php $nocommentsyet = "0"; ?>
    <?php echo $numbcomments,$nocommentsyet; ?>
    <?php if ($nocommentsyet == $numbcomments) { ?>

    <?php echo "True"; ?>
    <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

    <?php } else { ?>

    <?php echo "False"; ?>
    <form id="commentform" onsubmit="new Ajax.Updater({success: 'commentlist'}, '<?php bloginfo('stylesheet_directory') ?>/comments-ajax.php', {asynchronous: true, evalScripts: true, insertion: Insertion.Bottom, onComplete: function(request){complete(request)}, onFailure: function(request){failure(request)}, onLoading: function(request){loading()}, parameters: Form.serialize(this)}); return false;">

    <?php } ?>

    Problem is, the IF statement returns false every time no matter how many comments there are. What am I missing?

    Btw, those echos are in there so when I load a post I can see for myself the variables values and verify that the statement SHOULD be true… but it’s not…

    Or is there a simpler way that I don’t know?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try changing <?php $nocommentsyet = "0"; ?> to <?php $nocommentsyet = 0; ?>

    and <?php $numbcomments = comments_number('0', '1', '2'); ?> to <?php $numbcomments = get_comments_number($post->id); ?>

    That said, it’s a strange way of doing things and not at all one that I would advocate having two comment forms…

    Well, you have to have two comment forms incase a user doesn’t have javascript enabled, it’s a matter of how you use them. But how else would you do it? I know it seems werid…

    Changing what you told me to change did help, now the statement returns “True” all the time instead of false… 1 ==0 TRUE! No idea why…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘If/Then, Simple I know.. Please help’ is closed to new replies.