Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.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_Jquery_Wordpress_Html Table - Fatal编程技术网

Php 检查某列的单元格是否为空,如果所有单元格都为空,则隐藏整个列

Php 检查某列的单元格是否为空,如果所有单元格都为空,则隐藏整个列,php,jquery,wordpress,html-table,Php,Jquery,Wordpress,Html Table,我试图检查类为“checkthisone”的是否为空,以及它们是否为隐藏整个列。我正试图通过jquery实现这一点。这个表是在wordpress页面的循环中创建的,所以我找不到用php实现这一点的方法 表格HTML如下所示: <table> <tr> <th>header</th> <th id="checking-tds-header">header<

我试图检查类为“checkthisone”的
是否为空,以及它们是否为隐藏整个列。我正试图通过jquery实现这一点。这个表是在wordpress页面的循环中创建的,所以我找不到用php实现这一点的方法

表格HTML如下所示:

     <table>
          <tr>
            <th>header</th>
            <th id="checking-tds-header">header</th>
            <th>header</th>
          </tr>
          <tr>
            <td>info</td>
            <td class="checkthisone"></td>
            <td>info</td>
          </tr>
          <tr>
            <td>info</td>
            <td class="checkthisone"></td>
            <td>info</td>
          </tr>
    </table>

标题
标题
标题
信息
信息
信息
信息
显示该表的PHP代码如下:

我想在这段代码中检查类为“temizleme”的单元格。有关章节如下:

while ( $query->have_posts() ) : $query->the_post();
    ?>      
    <tr>
        <td>
            <a class="mangaep-episode" href="<?php the_permalink(); ?>"><?php echo get_post_meta( get_the_ID(), 'kacinci_bolum', true );  ?>
            <?php $bolum_aciklamasi = get_post_meta(get_the_ID(), 'bolum_aciklamasi', true);
                if ( ! empty ( $bolum_aciklamasi ) ) {  ?>          
                <span><?php echo $bolum_aciklamasi;  ?></span>
                <?php } ?>
            </a>    
        </td>
        <td><?php if(function_exists('the_views')) { the_views(); } ?></td>
        <td class="down"><?php echo get_post_meta( get_the_ID(), 'cevirmen', true );  ?></td>
        <td class="down"><?php echo get_post_meta( get_the_ID(), 'editor', true );  ?></td>
        <td class="down temizleme"><?php echo get_post_meta( get_the_ID(), 'temizleme', true );  ?></td> 
        <td class="down">
                <?php $indirme_linki = get_post_meta(get_the_ID(), 'indirme_linki', true);
                if ( ! empty ( $indirme_linki ) ) { ?>          
                <a target="_blank" href="<?php echo $indirme_linki;  ?>" class="mangaep-down">İNDİR</a>
                <?php } ?>                  
        </td>
    </tr>
while($query->have_posts()):$query->the_post();
?>      
尝试以下方法:

$(document).ready(function(){

   $(".checkthisone").each(function(){   // check each class
      if($(this).text() == ""){         // if the <td> has nothing in it, enter this condition
         $(this).parent("tr").hide();   // hide the entire <tr>
      }
   });
});

标题
标题
标题
信息
信息
信息
东西
信息
尝试以下方法:

$(document).ready(function(){

   $(".checkthisone").each(function(){   // check each class
      if($(this).text() == ""){         // if the <td> has nothing in it, enter this condition
         $(this).parent("tr").hide();   // hide the entire <tr>
      }
   });
});

标题
标题
标题
信息
信息
信息
东西
信息

最简单的解决方案是使用
:empty
选择器

$(“#检查tds标头”).hide();
$($td.checkthisone:empty”).hide()

标题
标题
标题
信息
信息
信息
信息

最简单的解决方案是使用
:empty
选择器

$(“#检查tds标头”).hide();
$($td.checkthisone:empty”).hide()

标题
标题
标题
信息
信息
信息
信息

排除PHP中的

要排除整行,请执行以下操作:

  • 在while循环开始时获取post_元值
  • 检查它是否为空
  • 如果该行不为空,则显示该行
  • 例如,要检查post_meta中的
    temizleme
    中的值:

    <?php
    while ( $query->have_posts() ) : $query->the_post();
    
       /* 1. Get the post_meta value of temizleme */
       $temizleme = get_post_meta( get_the_ID(), 'temizleme', true );
    
        /* 2. check if temizleme has a value */
        if (!empty($temizleme)) {
    
            /* 3. if temizleme isn't empty, display the row */
            ?>      
            <tr>
                <td>
                    <a class="mangaep-episode" href="<?php the_permalink(); ?>"><?php echo get_post_meta( get_the_ID(), 'kacinci_bolum', true );  ?>
                    <?php $bolum_aciklamasi = get_post_meta(get_the_ID(), 'bolum_aciklamasi', true);
                        if ( ! empty ( $bolum_aciklamasi ) ) {  ?>          
                        <span><?php echo $bolum_aciklamasi;  ?></span>
                        <?php } ?>
                    </a>    
                </td>
                <td><?php if(function_exists('the_views')) { the_views(); } ?></td>
                <td class="down"><?php echo get_post_meta( get_the_ID(), 'cevirmen', true );  ?></td>
                <td class="down"><?php echo get_post_meta( get_the_ID(), 'editor', true );  ?></td>
                <td class="down temizleme"><?php echo get_post_meta( get_the_ID(), 'temizleme', true );  ?></td> 
                <td class="down">
                    <?php $indirme_linki = get_post_meta(get_the_ID(), 'indirme_linki', true);
                    if ( ! empty ( $indirme_linki ) ) { ?>          
                        <a target="_blank" href="<?php echo $indirme_linki;  ?>" class="mangaep-down">İNDİR</a>
                    <?php } ?>                  
                </td>
            </tr>
    
        <?php  } /* 3. end if (!empty(temizleme)) */  ?>    
    
    <?php  endwhile; ?> 
    

    在PHP中隐藏列

    要检查列的值,您需要:

  • 循环浏览帖子,将值保存到数组中
  • 检查数组中“temizleme”的所有值,如果其中任何一个有值,则设置显示表时要使用的标志(例如,在下面的示例中,我们将
    $bTemizlemeColumnIsEmpty
    设置为false)
  • 循环遍历数据数组以显示表中的信息。如果我们的标志指示列为空(即
    $bTemizlemeColumnIsEmpty
    为真),则不显示“temizleme”的
  • 例如:

    <?php
    
    $postdata = array(); /* array to save data for ALL posts */
    
    while ( $query->have_posts() ) : $query->the_post();
    
       /* 1. Save all the post data in an array */
       $row = array(); /* array to save data for THIS post */
    
       $row["temizleme"] = get_post_meta( get_the_ID(), 'temizleme', true );
       $row["kacinci_bolum"] = get_post_meta( get_the_ID(), 'kacinci_bolum', true );
       $row["bolum_aciklamasi"] = get_post_meta( get_the_ID(), 'bolum_aciklamasi', true );
    
       [etc...]
    
       $postdata[]  = $row; /* add this data to the $postdata array */
    <?php  endwhile;   ?>   
    
    
    /* 2. check the values of temizleme */
    
    $bTemizlemeColumnIsEmpty = true;
    foreach ($postdata as $row)
        if (!empty($row["temizleme"]))  $bTemizlemeColumnIsEmpty = false;
    
    /* if any of the cells have a value, $bTemizlemeColumnIsEmpty will be false after we finish this loop */
    
    
    /* 3. now loop through all the row to display the table */
    foreach ($postdata as $row){
    ?>
         <tr>
            <td>
                    <a class="mangaep-episode" href="<?php the_permalink(); ?>"><?php echo $row["kacinci_bolum"];  ?>
                    <?php if ( ! empty ( $row["bolum_aciklamasi"] ) ) { ?>          
                        <span><?php echo $row["bolum_aciklamasi"];  ?></span>
                        <?php } ?>
                    </a>    
                </td>
                <td><?php if(function_exists('the_views')) { the_views(); } ?></td>
                <td class="down"><?php echo $row["cevirmen"];  ?></td>
                <td class="down"><?php echo $row["editor"];  ?></td>
    
                <?php 
                /* 4. only display this td if  $bTemizlemeColumnIsEmpty is false */
                if ( !$bTemizlemeColumnIsEmpty ){
                ?>
                    <td class="down temizleme"><?php echo $row["temizleme"];  ?></td> 
                <?php  }   ?>   
    
    
                <td class="down">
                    <?php if ( ! empty ( $row["indirme_linki"] ) ) {    ?>          
                        <a target="_blank" href="<?php echo $row["indirme_linki"];  ?>" class="mangaep-down">İNDİR</a>
                    <?php } ?>                  
                </td>
        </tr>
    
    <?php  } /* end foreach */  ?>  
    
    
    /* 2. 检查temizleme的值*/
    $bTemizlemeColumnIsEmpty=true;
    foreach($postdata作为$row)
    如果(!empty($row[“temizleme”])$bTemizlemeColumnIsEmpty=false;
    /*如果任何单元格具有值,$bTemizlemeColumnIsEmpty在完成此循环后将为false*/
    /* 3. 现在遍历所有行以显示表*/
    foreach($postdata作为$row){
    ?>
    
    排除PHP中的

    要排除整行,请执行以下操作:

  • 在while循环开始时获取post_元值
  • 检查它是否为空
  • 如果该行不为空,则显示该行
  • 例如,要检查post_meta中的
    temizleme
    中的值:

    <?php
    while ( $query->have_posts() ) : $query->the_post();
    
       /* 1. Get the post_meta value of temizleme */
       $temizleme = get_post_meta( get_the_ID(), 'temizleme', true );
    
        /* 2. check if temizleme has a value */
        if (!empty($temizleme)) {
    
            /* 3. if temizleme isn't empty, display the row */
            ?>      
            <tr>
                <td>
                    <a class="mangaep-episode" href="<?php the_permalink(); ?>"><?php echo get_post_meta( get_the_ID(), 'kacinci_bolum', true );  ?>
                    <?php $bolum_aciklamasi = get_post_meta(get_the_ID(), 'bolum_aciklamasi', true);
                        if ( ! empty ( $bolum_aciklamasi ) ) {  ?>          
                        <span><?php echo $bolum_aciklamasi;  ?></span>
                        <?php } ?>
                    </a>    
                </td>
                <td><?php if(function_exists('the_views')) { the_views(); } ?></td>
                <td class="down"><?php echo get_post_meta( get_the_ID(), 'cevirmen', true );  ?></td>
                <td class="down"><?php echo get_post_meta( get_the_ID(), 'editor', true );  ?></td>
                <td class="down temizleme"><?php echo get_post_meta( get_the_ID(), 'temizleme', true );  ?></td> 
                <td class="down">
                    <?php $indirme_linki = get_post_meta(get_the_ID(), 'indirme_linki', true);
                    if ( ! empty ( $indirme_linki ) ) { ?>          
                        <a target="_blank" href="<?php echo $indirme_linki;  ?>" class="mangaep-down">İNDİR</a>
                    <?php } ?>                  
                </td>
            </tr>
    
        <?php  } /* 3. end if (!empty(temizleme)) */  ?>    
    
    <?php  endwhile; ?> 
    

    在PHP中隐藏列

    要检查列的值,您需要:

  • 循环浏览帖子,将值保存到数组中
  • 检查数组中“temizleme”的所有值,如果其中任何一个有值,则设置显示表时要使用的标志(例如,在下面的示例中,我们将
    $bTemizlemeColumnIsEmpty
    设置为false)
  • 循环遍历数据数组以显示表中的信息。如果我们的标志指示列为空(即
    $bTemizlemeColumnIsEmpty
    为真),则不显示“temizleme”的
  • 例如:

    <?php
    
    $postdata = array(); /* array to save data for ALL posts */
    
    while ( $query->have_posts() ) : $query->the_post();
    
       /* 1. Save all the post data in an array */
       $row = array(); /* array to save data for THIS post */
    
       $row["temizleme"] = get_post_meta( get_the_ID(), 'temizleme', true );
       $row["kacinci_bolum"] = get_post_meta( get_the_ID(), 'kacinci_bolum', true );
       $row["bolum_aciklamasi"] = get_post_meta( get_the_ID(), 'bolum_aciklamasi', true );
    
       [etc...]
    
       $postdata[]  = $row; /* add this data to the $postdata array */
    <?php  endwhile;   ?>   
    
    
    /* 2. check the values of temizleme */
    
    $bTemizlemeColumnIsEmpty = true;
    foreach ($postdata as $row)
        if (!empty($row["temizleme"]))  $bTemizlemeColumnIsEmpty = false;
    
    /* if any of the cells have a value, $bTemizlemeColumnIsEmpty will be false after we finish this loop */
    
    
    /* 3. now loop through all the row to display the table */
    foreach ($postdata as $row){
    ?>
         <tr>
            <td>
                    <a class="mangaep-episode" href="<?php the_permalink(); ?>"><?php echo $row["kacinci_bolum"];  ?>
                    <?php if ( ! empty ( $row["bolum_aciklamasi"] ) ) { ?>          
                        <span><?php echo $row["bolum_aciklamasi"];  ?></span>
                        <?php } ?>
                    </a>    
                </td>
                <td><?php if(function_exists('the_views')) { the_views(); } ?></td>
                <td class="down"><?php echo $row["cevirmen"];  ?></td>
                <td class="down"><?php echo $row["editor"];  ?></td>
    
                <?php 
                /* 4. only display this td if  $bTemizlemeColumnIsEmpty is false */
                if ( !$bTemizlemeColumnIsEmpty ){
                ?>
                    <td class="down temizleme"><?php echo $row["temizleme"];  ?></td> 
                <?php  }   ?>   
    
    
                <td class="down">
                    <?php if ( ! empty ( $row["indirme_linki"] ) ) {    ?>          
                        <a target="_blank" href="<?php echo $row["indirme_linki"];  ?>" class="mangaep-down">İNDİR</a>
                    <?php } ?>                  
                </td>
        </tr>
    
    <?php  } /* end foreach */  ?>  
    
    
    /*2.检查temizleme的值*/
    $bTemizlemeColumnIsEmpty=true;
    foreach($postdata作为$row)
    如果(!empty($row[“temizleme”])$bTemizlemeColumnIsEmpty=false;
    /*如果任何单元格具有值,$bTemizlemeColumnIsEmpty在完成此循环后将为false*/
    /*3.现在遍历所有行以显示表*/
    foreach($postdata作为$row){
    ?>
    
    我认为代码“$”(“#检查tds标头”).hide()”直接隐藏标头。我想检查该列中的所有单元格是否为空。我需要在检查后用单元格隐藏标头。我认为代码“$(“#检查tds标头”).hide()”直接隐藏标题。我想检查该列中的所有单元格是否为空。我需要在检查后用单元格隐藏标题。这在PHP中应该是完全可以实现的,而且最好是