2017-02-20 45 views
-1

我正在一个网站上工作。在某个页面上,有一个div元素显示来自PHP文件的值。div元素输出错误

这PHP代码呈现的HTML显示的信息:

$output .= ' 

      <div class="row text-left col-md-3 col-md-offset-1 "> 
      <h5><strong>Doctor '.$row['nombre_doctor'].' '.$row['apellidos_doctor'].'</strong></H5> 
      <h6>'.$row['especialidad_doctor'].'<H6> 
      <h6>'.$orden.' de '.get_num_doctores($row['ciudad_doctor'],$row['especialidad_doctor']).' doctores en '.$row['ciudad_doctor'].'<H6>'; 

     if ($puntos_doctores == 0){ 
     $output .= '  <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-0.png" /> ' 
     .$num_opiniones.' opiniones <H6><br>'; 
      } 
     if ($puntos_doctores > 0 && $puntos_doctores <= 0.5){ 
     $output .= '  <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-05.png" /> ' 
     .$num_opiniones.' opiniones <H6><br>'; 
      } 
     if ($puntos_doctores > 0.5 && $puntos_doctores <= 1){ 
     $output .= '  <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-01.png" /> ' 
     .$num_opiniones.' opiniones <H6><br>'; 
      } 
     if ($puntos_doctores > 1 && $puntos_doctores <= 1.5){ 
     $output .= '  <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-15.png" /> ' 
     .$num_opiniones.' opiniones <H6><br>'; 
      } 
     if ($puntos_doctores > 1.5 && $puntos_doctores <= 2){ 
     $output .= '  <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-2.png" /> ' 
     .$num_opiniones.' opiniones <H6><br>'; 
      } 
      if ($puntos_doctores > 2 && $puntos_doctores <= 2.5){ 
     $output .= '  <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-25.png" /> ' 
     .$num_opiniones.' opiniones <H6><br>'; 
      } 
      if ($puntos_doctores > 2.5 && $puntos_doctores <= 3){ 
     $output .= '  <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-3.png" /> ' 
     .$num_opiniones.' opiniones <H6><br>'; 
      } 
      if ($puntos_doctores > 3 && $puntos_doctores <= 3.5){ 
     $output .= '  <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-35.png" /> ' 
     .$num_opiniones.' opiniones <H6><br>'; 
      } 
      if ($puntos_doctores > 3.5 && $puntos_doctores <= 4){ 
     $output .= '  <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-4.png" /> ' 
     .$num_opiniones.' opiniones <H6><br>'; 
      } 
      if ($puntos_doctores > 4 && $puntos_doctores <= 4.5){ 
     $output .= '  <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-45.png" /> ' 
     .$num_opiniones.' opiniones <H6><br>'; 
      } 
      if ($puntos_doctores > 4.5 && $puntos_doctores <= 5){ 
     $output .= '  <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-5.png" /> ' 
     .$num_opiniones.' opiniones <H6><br>'; 
      } 


    $output .= ' <a class="btn btn-large btn-info" href="doctor_info.php">+ Info</a> 

      </div> 

     '; 
} 
echo $output; 

输出没有显示如预期的元素。 在这里,你有截图明白我的意思: enter image description here

的元素由点数量排序,从5到0

我希望他们出现在一排3列然后用剩下的物品再放一行。目前,造型已关闭。 Cardio1元素位于新的一行并向右偏移,并且Cardio4元素再次位于新行。

编辑以显示完整的PHP部分:

$sql = "SELECT * FROM tb_doctores WHERE especialidad_doctor LIKE '%".$_POST["especialidad_doctor"]."%' 
     AND pais_doctor LIKE '%".$_POST["pais_doctor"]."%' 
     AND estado_doctor LIKE '%".$_POST["estado_doctor"]."%' 
       AND ciudad_doctor LIKE '%".$_POST["ciudad_doctor"]."%' ORDER BY media_puntos DESC"; 
$result = mysqli_query($conn, $sql); 
if(mysqli_num_rows($result) > 0) 
{//05 

     $output .= '<h3>Resultados por *'.$_POST['especialidad_doctor']. '* </h3>'; 
     $orden = 0; 
    while($row = mysqli_fetch_array($result)) 
    {//06 
     $num_opiniones = get_num_opiniones($row['codigo_doctor']); 
     $num_doctores = get_num_doctores($row['ciudad_doctor'],$row['especialidad_doctor']); 
     $puntos_doctores = get_puntos_opiniones($row['codigo_doctor']); 
     $puntos_doctores = (float)$puntos_doctores; 
     $orden = get_orden($row['especialidad_doctor'],$row['codigo_doctor'],$row['pais_doctor'],$row['ciudad_doctor']); 

if ($puntos_doctores == 0){ 
    $img = '0'; 
} else if ($puntos_doctores > 0 && $puntos_doctores <= 0.5){ 
    $img = '05'; 
} else if ($puntos_doctores > 0.5 && $puntos_doctores <= 1){   
    $img = '01'; 
} 
else if ($puntos_doctores > 1 && $puntos_doctores <= 1.5){   
    $img = '15'; 
} 
else if ($puntos_doctores > 1.5 && $puntos_doctores <= 2){   
    $img = '2'; 
} 
else if ($puntos_doctores > 2 && $puntos_doctores <= 2.5){   
    $img = '25'; 
} 
else if ($puntos_doctores > 2.5 && $puntos_doctores <= 3){   
    $img = '3'; 
} 
else if ($puntos_doctores > 3 && $puntos_doctores <= 3.5){   
    $img = '35'; 
} 
else if ($puntos_doctores > 3.5 && $puntos_doctores <= 4){   
    $img = '4'; 
} 
else if ($puntos_doctores > 4 && $puntos_doctores <= 4.5){   
    $img = '45'; 
} 
else if ($puntos_doctores > 4.5 && $puntos_doctores <= 5){   
    $img = '5'; 
} 


$output .= ' 
     <div class="row"> 
      <div class="col-md-2"> 
      <h5><strong>Doctor '.$row['nombre_doctor'].' '.$row['apellidos_doctor'].'</strong></H5> 
      <h6>'.$row['especialidad_doctor'].'<H6> 
      <h6>'.$orden.' de '.get_num_doctores($row['ciudad_doctor'],$row['especialidad_doctor']).' doctores en '.$row['ciudad_doctor'].'<H6> 
      <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-' . $img . '.png" /> ' .$num_opiniones. ' opiniones <H6><br> 
      <a class="btn btn-large btn-info" href="doctor_info.php">+ Info</a> 
     </div> 
     </div> 
    '; 
    } 

echo $output; 




}//05 
+0

请解释您的意思:输出结果并未按预期显示元素。 您是否指的是Cardio1一路走到最后,然后又出现一条新线,Cardio4在下一条线上? –

+0

你可以显示生成的HTML(在浏览器中,查看源代码)和CSS。这将有更多的帮助。 –

+0

@ShawnNorthrop,是的。我想根据点数显示从左到右排列的元素。 – mvasco

回答

1

假设你有一个循环,在输出这些医生

请尝试以下:

$output .= '<div class="row">'; 

foreach($pointsArray as $putos_doctores){ 

    if ($puntos_doctores == 0){ 
    $img = '0'; 
    } else if ($puntos_doctores > 0 && $puntos_doctores <= 0.5){ 
    $img = '05'; 
    } else if ($puntos_doctores > 0.5 && $puntos_doctores <= 1){   
     $img = '01'; 
    } ...... finish your points else if 

    $output .= '<div class="col-md-4"> 
       <h5><strong>Doctor '.$row['nombre_doctor'].' '.$row['apellidos_doctor'].'</strong></H5> 
       <h6>'.$row['especialidad_doctor'].'<H6> 
       <h6>'.$orden.' de '.get_num_doctores($row['ciudad_doctor'],$row['especialidad_doctor']).' doctores en '.$row['ciudad_doctor'].'<H6>'; 
       <h6>'.$puntos_doctores.'<img class="img-responsive" width="150px" src="imagenes/estrellas/corazones-' . $img . '.png" /> ' .$num_opiniones. ' opiniones <H6><br> 
       <a class="btn btn-large btn-info" href="doctor_info.php">+ Info</a> 
      </div>'; 
} 

$output .= '</div>'; 
echo $output; 
+0

我现在只有一列 – mvasco

+0

我打扫得更多 –

+0

仍然需要造型调整,虽然 –

0

你应该应用此过程中得到listin

​​