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

PHP函数创建幻灯片

PHP函数创建幻灯片,php,jquery,html,slideshow,Php,Jquery,Html,Slideshow,我目前正在使用PHP函数创建一个幻灯片,从数据库中提取图像 我还想在主页幻灯片中使用这些图像中的一个,但仅当数据库中的项目本身被标记为“功能”标记时,我才想提取一个图像,我需要如何创建一个函数来实现这一点?这是我的标记功能和幻灯片功能: if(strtolower($term) == 'feature') { $query = "select * FROM $table WHERE (tags LIKE '%feature%') ORDER BY rid DESC LIMIT 5"; }

我目前正在使用PHP函数创建一个幻灯片,从数据库中提取图像

我还想在主页幻灯片中使用这些图像中的一个,但仅当数据库中的项目本身被标记为“功能”标记时,我才想提取一个图像,我需要如何创建一个函数来实现这一点?这是我的标记功能和幻灯片功能:

if(strtolower($term) == 'feature') {
    $query = "select * FROM $table WHERE (tags LIKE '%feature%') ORDER BY rid DESC LIMIT 5";
}
在单独的PHP函数文件中-

if (trim(mysql_result($this->result,0,"imageCarousel1") != '')) {
    $this->hassliderimage1 = true;
} else {
    $this->hassliderimage1 = false;
}

public function show_image_carousel1() {
    echo ('<img class="img-responsive" src="'.$this->directory.mysql_result($this->result,0,"imageCarousel1").'" />');
}
if(trim(mysql_结果($this->result,0,“imageCarousel1”)!=''){
$this->hasliderimage1=true;
}否则{
$this->hasliderimage1=false;
}
公共功能显示\图像\旋转木马1(){
echo('directory.mysql_result($this->result,0,“imageCarousel1”)。“/>”;
}
然后,幻灯片将显示在带有以下内容的页面上:

<div>
<?php if ($recipe->hassliderimage1 == true) { 
        $recipe->show_image_carousel1();
} ?>
</div>

我会采用以下方法

首先,从javascript数组中的一些静态数据创建一个纯HTML、CSS的幻灯片。测试它是否按照您的要求工作[在主页sideshow中使用一个图像进行幻灯片演示]

现在,下一部分将使用php用数据库中的动态数据替换静态数据,并将数据作为JSON响应发送。接受此JSON响应并使用JSON.parseJSON(数据)转换为javascript对象

现在,下一部分是关于在PHP中创建动态数据的业务逻辑:

  • 仅当数据库中的项目本身被标记为“功能”标记时,才希望提取图像

    $query=“从$table中选择*,其中标记“%feature%”按rid DESC LIMIT 5排序

  • 在主页幻灯片中使用这些图像之一

    用一些额外的数据标记您的特殊图像,并在将数据注入幻灯片时对其进行识别


  • 好的,所以我最后做的是…对每个标签进行“搜索”-即slide1,slide2,slide3,slide4,slide5用于幻灯片放映-数据库将包含这些标签-这是我用于它的php搜索

          <?php if ($searchTerm != '') { ?>
              <?php 
                  $result = searchRecipes('slide1','');
                  while ($row = mysql_fetch_assoc($result)) {
                    if($row['imageCarousel1'] != '') { 
                      $slide1 = '<img class="active" alt="slide1" src="/images/recipes/'.$row['imageCarousel1'].'" />';
                    } 
    
                  ?>
    
    
    
    然后根据幻灯片在html中的位置将图像放置在它的位置-因此我有5个php搜索5张幻灯片…虽然我猜这可能不是最好的选择

        <a href="recipe_display.php?r=<?=$row['rid'];?>"><?=$slide1;?></a>
      <div class="carousel-caption">
         <a href="recipe_display.php?r=<?=$row['rid'];?>"><h4><?=$row['name'];?></h4></a>
      </div>