从2个表中获取记录并检查是否存在提交的复选框id值

时间:2017-08-14 06:10:17

标签: php pdo

我有这个表格从

获取复选框结果
  1. 标记
  2. 现在我希望比较提交的帖子ID和值是否存在于表中并抛出错误

    $stmt = $db->prepare('SELECT * FROM posts_tags WHERE post_id = :post_id AND tag_id = :tag_id');
            $stmt->bindParam(':post_id', $postID, PDO::PARAM_INT);
            $stmt->bindParam(':tag_id', $postTag, PDO::PARAM_INT);
            $r = $stmt->rowCount();
    
            if(!empty($r)){
                $error[] = 'Please do not select exsisting tag.';
    }
    

    以下是我的表格中的一些代码

    <input type='hidden' name='postID' value='<?php echo $row['postID'];?>'>
    <p><label>Tags</label><br />
            <div class="boxcheck">
            <?php                   
                        $stmt = $db->prepare('select * from blog_tags');
                        $stmt->execute();
                        $tag = $stmt->fetchAll();
                        foreach($tag as $tags){
                        ?>
                        <input type="checkbox" name="postTag[]" value="<?php echo $tags['tagID']; ?>"> <?php echo $tags['tagName']; ?><br /> 
    
                        <?php
                        }
                        ?>
    

    我可能会做什么,因为错误不会发生?

    感谢您的帮助

1 个答案:

答案 0 :(得分:0)

1st: <jee:jndi-lookup id="connectionFactoryBean" jndi-name="dpxcomConnectionFactory"/> <bean id="dpxcomJMSConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"> <constructor-arg ref="connectionFactoryBean"/> <property name="sessionCacheSize" value="50"/> </bean> Route definition: from("jms:queue:./DPXCOM!"+config.getMainQueueName()+"?concurrentConsumers="+config.getConcurrentConsumers() +"&maxConcurrentConsumers="+config.getConcurrentConsumers()+"&jmsMessageType=Text&testConnectionOnStartup=true&connectionFactory=dpxcomJMSConnectionFactory&consumerType=Simple") .setHeader("jmsMessage").body() .process(new VerifyJMSMessageProcessor()) .choice() .. .. end(); 是将数据绑定为int的数组。

第二名:您需要在查询中使用$postTag子句

第3名:您需要以这种方式绑定值。

IN