2017-02-20 135 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

​​