首页 > 解决方案 > 在我的 mysql 表中,在一个单元格中有行,我有数组。如何选择具有特定数组值的行?

问题描述

postCategory 列具有类似的数组

Array
(
    [0] => movie news
    [1] => breaking news
    [2] => political news
)   

//所以请告诉我如何选择数据

<?php

$select_posts = "select * 
                 from blogposts 
                 where postCategory = 'political news' 
                 IN(postCategory) 
                 order by postId DESC 
                 LIMIT 1,6";

$run_posts = mysqli_query($con,$select_posts);

while($row=mysqli_fetch_array($run_posts)){

    $postId = $row['postId']; 
    $postTitle = $row['postTitle'];
    $postContent = $row['postContent'];
    $futureImage = $row['futureImage'];
    $postCategory = $row['postCategory'];
    $postTags = $row['postTags'];
    $postAuthor = $row['postAuthor'];
    $postDate = $row['postDate'];


?>  

    <!--Widget Post-->
    <!--Widget Post-->
    <article class="widget-post" style="padding-left:0px;min-height: 40px;   margin-bottom: 14px;">
        <div class="text" style="">
            <a href="blog-single.php?id=<?php echo $postId; ?>?postTitle=<?php echo str_replace(' ', '-', $postTitle);?>"> <?php echo substr($postTitle,0,60); ?> 
            </a>
        </div>
    </article>
<?php } ?>    

标签: phparraysmysqli

解决方案


推荐阅读