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
jQueryUI选项卡和php回显数据_Php_Jquery_Mysql_Html - Fatal编程技术网

jQueryUI选项卡和php回显数据

jQueryUI选项卡和php回显数据,php,jquery,mysql,html,Php,Jquery,Mysql,Html,我正在使用 我想通过使用php从mysql数据库获取选项卡来实现动态,但不确定如何根据表中的行数添加片段1、2、3。 例如,有5行,这意味着有5个片段。以下是jquery ui的html代码 <div id="featured" > <ul class="ui-tabs-nav"> <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1"><a href="

我正在使用

我想通过使用php从mysql数据库获取选项卡来实现动态,但不确定如何根据表中的行数添加片段1、2、3。 例如,有5行,这意味着有5个片段。以下是jquery ui的html代码

<div id="featured" >
    <ul class="ui-tabs-nav">
        <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-1"><a href="#fragment-1"><img class="thumb" src="http://upload.wikimedia.org/wikipedia/en/thumb/0/0f/Avs38.jpg/250px-Avs38.jpg" alt="" /><span>15+ Excellent High Speed Photographs</span></a></li>
            <li class="ui-tabs-nav-item" id="nav-fragment-2"><a href="#fragment-2"><img class="thumb" src="http://www.crunchbase.com/assets/images/original/0007/5132/75132v1.jpg" alt="" /><span>20 Beautiful Long Exposure Photographs</span></a></li>  
    </ul>
    <!-- First Content -->
    <div id="fragment-1" class="ui-tabs-panel" style="">
        <img src="image.jpg" alt="" />
        <div class="info" >
        <h2><a href="#" >Loerm Ipsum</a></h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla tincidunt condimentum lacus. Pellentesque ut diam....<a href="#" >read more</a></p>
        </div>
    </div>

</div>

Lorem ipsum dolor sit amet,是一位杰出的献身者。无味调味品。佩伦茨克ut直径

通常我会使用这段php代码来回显数据库

  <?php
           $rows = array();
    while($row = mysql_fetch_array( $query )){

      $rows[] = $row;

      echo "'Some html code data $row[image] test'\n";
      }

    }

    ?>

如果您谈论的是选项卡的初始加载,那么请修改代码,使其具有计数器,并将该计数器的值输出到选项卡片段,如下所示:

<?php
    $count = 0; // Initialize counter
    $rows = array();
    while($row = mysql_fetch_array( $query )) {
        $rows[] = $row;
        echo '<div id="fragment-' . ++$count . '" class="ui-tabs-panel" style="">';
        echo "'Some html code data $row[image] test'\n";
    }
?>

<div id="fragment-1" class="ui-tabs-panel" style="">
            <img src="image.jpg" alt="" />
            <div class="info" >
            <h2><a href="#" >Loerm Ipsum</a></h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla tincidunt condimentum lacus. Pellentesque ut diam....<a href="#" >read more</a></p>
            </div>
        </div>
<div id="fragment-2" class="ui-tabs-panel" style="">
            <img src="image2.jpg" alt="" />
            <div class="info" >
            <h2><a href="#" >Loerm Ipsum2</a></h2>
            <p>L2222<a href="#" >read more</a></p>
            </div>
</div>
<?php
    $count = 0; // Initialize counter
    $rows = array();
    while($row = mysql_fetch_array( $query )) {
        $rows[] = $row;
        echo '<div id="fragment-' . ++$count . '" class="ui-tabs-panel" style="">';
        echo "'Some html code data $row[image] test'\n";
    }
?>
<?php
    $rows = array();
    $frag = 1;
    while($row = mysql_fetch_array( $query )){

       $rows[] = $row;
       echo "fragment-$frag";
       echo "'Some html code data $row[image] test'\n";
       $frag++;
  }

}

?>