数据未显示如果有3个数据

时间:2015-06-22 16:29:28

标签: php mysql ajax

我已经创建了页面学校和广告

此页面显示如下

学校1 - 学校2 - 学校3

ADS1

学校4 - 学校5 - 学校6

ADS2

学校7 - 学校8 - 学校9

广告默认<<循环播放广告时

但是当我搜索1所学校时,我有问题 这个学校没有显示,我知道这个学校没有显示因为结果查询不是multipe 3数据。如果我的查询结果为1或2个数据。此页面不显示此结果,因为此结果不是多个3数据。

这是我的网站:http://www.tingali.com/pencarian.html enter image description here

您可以搜索并输入" MA AL KARIMIYAH "

这是我的脚本: 的 pagging_page3.php

<?php
include('connection.php');
$limit = 24;
$adjacent = 3;

if(isset($_REQUEST['actionfunction'])  && $_REQUEST['actionfunction']!=''){
$actionfunction = $_REQUEST['actionfunction'];


   call_user_func($actionfunction,$_REQUEST,$con,$limit,$adjacent);
}
function showData($data,$con,$limit,$adjacent){
  $page  = $data['page'];
  $dt    = $_POST['dt'];

   if($page==1){
   $start = 0;  
  }
  else{
  $start = ($page-1)*$limit;
  }

      $sqlo  = "select * from schools where showschool='YES' ".$dt." and typeschool='school' order by paid,urut  asc";
      $sql   = stripslashes($sqlo);
      $rows  = $con->query($sql);
      $rows  = $rows->num_rows;

      $sqlo = "select * from schools where showschool='YES' ".$dt." and typeschool='school' order by paid,urut  asc limit $start,$limit";
      $sql   = stripslashes($sqlo);


  $data = $con->query($sql);
  $str='';
  $i=0; 
  $k=0;
  $m =1;
  $rumus = $page * ($limit / $adjacent); // bntr
  $data_web = mysqli_query($con,"SELECT * from web");
  $wew = ($page - 1) * 8;
  $row2 = mysqli_fetch_object($data_web);

   while($row = $data->fetch_array(MYSQLI_ASSOC)){

    // This Data Ads
   if($i % 3 == 0) 
    {
        $data_ads = mysqli_query($con,"SELECT * from ads limit $wew,1");
        $rowads = mysqli_fetch_object($data_ads);
            $str = is_null($rowads->link) ? "<a href='#'><img src='images/ads/default/default.jpg' alt=''></a>":"<a href='".$rowads->link."'><img src='images/ads/default/".$rowads->file."' alt=''></a>";
            $wew++;
    }


        // This Data School
            $jd = $row['link'];
            $data_sl = mysqli_query($con,"SELECT count(kode) as counter FROM `school_counter` where kode ='".$row['kode']."' and visit between '".$row2->range_start."' AND '".$row2->range_end."' ");
            $sl = mysqli_fetch_object($data_sl);
            $str.=" <li class='col-lg-4 col-md-4 col-sm-4 col-xs-4'>
            <div class='product_item'>
            <div>
            <a href='".$jd."'>
            <img height='228px' width='224px' src='images/sekolah/logo/".$row['logo']."' class='c_image_1' alt=''>
            </a>
            </div>
            <div class='product_info'>
            <a href='".$jd."'><h4>".$row['name_school']."</h4></a>
            <div class='clearfix'>
            <font size='2' color='blue'>Dilihat : ".$sl->counter." </font></br>
            <i class='fa fa-home'></i> : ".$row['addres']."<br/>
            </div>
            </div>
            </div>
            </li>
            ";
    $i++;
    if ($i%3 == 0) {
        echo $str; 
        }
   }
?>

帮助我谢谢

1 个答案:

答案 0 :(得分:0)

尝试更改

$ nodemon debug -w . app.js

$adjacent = 3;