使用引号

时间:2017-10-04 20:34:22

标签: php html

我有一个问题试图让一个选择标签与php一起工作我已经尝试了很多方法在php中处理select标签,但它不起作用。我需要select标签显示查询的结果在里面。我不知道如何解决它,我需要一些帮助。 这是我的代码 先谢谢

<?php 
                $sql1 = mysql_query("SELECT * FROM `metlab`.`cutlog_junta` WHERE `finalizado` = 0")or die (mysql_error());
                $idtimeleft= 0;
                while($array = mysql_fetch_array($sql1, MYSQL_BOTH)){
                    $idtimeleft++;                      
                    $idprueba = $array[0];
                    $id_log = $array["id_log"];
                    $id_operador = $array["id_operador"];
                    $started = $array["started"];
                    $finished = $array["finished"];
                    date_default_timezone_set("America/Mexico_City");
                    $tiempo1 = new DateTime('now');
                    $tiempo2 = new DateTime($finished);
                    if ($tiempo1 < $tiempo2){
                    $tiemporestante = date_diff($tiempo2,$tiempo1 );
                    $timeleft = $tiemporestante->format("%h:%i:%s");
                    }else{
                    $timeleft = "00:00:00";
                    }                       
                    $sql = mysql_query("SELECT r.job AS JOB,p.heat_code AS HEAT_CODE,p.probeta AS PROBETA,p.id_line AS ID_LINE,p.id_box_pin AS ID_BOX_PIN,p.id_conexion AS ID_CONEXION
                                        FROM metlab.prueba_junta p
                                        INNER JOIN metlab.requerimientos_junta r ON p.id_job=r.id WHERE p.id='".$id_log."'")or die (mysql_error());
                    $mhs = mysql_fetch_array($sql);                     
                    echo (" <tr id='row". $idtimeleft ."'>
                                <td><input type='checkbox' name='record'></td>
                                <td>" . $id_log . "</td>
                                <td>" . $mhs['JOB'] . "</td>
                                <td>" . $mhs['ID_BOX_PIN'] . "</td>
                                <td>" . $mhs['ID_CONEXION'] . "</td>
                                <td>" . $mhs['HEAT_CODE'] . "</td>
                                <td>" . $mhs['PROBETA'] . "</td>
                                <td>" . $mhs['ID_LINE'] . "</td>
                                <td>" . $started . "</td>                           
                                <td><div id='idtimeleft" . $idtimeleft ."'>" . $timeleft . "</div></td>
                                <td><button type='button' class='btn btn-primary' data-toggle='modal' data-target='#cut_process'><i class='fa fa-cog fa-spin'></i>CUT</button>
                                        <div id='cut_process' class='modal fade' role='dialog'>
                                          <div class='modal-dialog'>
                                            <div class='modal-content'>
                                              <div class='modal-header'>
                                                <button type='button'class='close' data-dismiss='modal'>&times;</button>
                                                <h4 class='modal-title'>CUT PROCESS</h4>
                                              </div>
                                              <div class='modal-body'>
                                                <input type='text' placeholder='INSERT COMMENT' class='form-control'><br>
                                                    <label>Supervisor:</label>
                                                    <select class='btn btn-primary'>
                                                        <?php //////////////////////////////problem
                                                        $query='SELECT nombre
                                                        FROM metlab.supervisores';
                                                        $result1=mysql_query($query);
                                                        while($row1=mysql_fetch_array($result1)):;?>
                                                        <option><?php echo $row1[0];?>
                                                        </option>
                                                        <?php endwhile;?>
                                                    </select> /////////////////////////////end problem
                                                </div>
                                              <div class='modal-footer'>
                                                <button type='button' class='btn btn-success' data-dismiss='modal'><i class='fa fa-paper-plane'></i>SEND COMMENT</button>

                                              </div>
                                            </div>

                                          </div>
                                        </div>
                                </td>
                                <td>
                                    <button type='button' class='btn btn-warning' data-toggle='modal' data-target='#milling_process'><i class='fa fa-cog fa-spin'></i>MILLING</button>
                                        <div id='milling_process' class='modal fade' role='dialog'>
                                          <div class='modal-dialog'>
                                            <div class='modal-content'>
                                              <div class='modal-header'>
                                                <button type='button'class='close' data-dismiss='modal'>&times;</button>
                                                <h4 class='modal-title'>MILLING PROCESS</h4>
                                              </div>
                                              <div class='modal-body'>
                                                <input type='text' placeholder='INSERT COMMENT' class='form-control'>
                                              </div>
                                              <div class='modal-footer'>
                                                <button type='button' class='btn btn-success' data-dismiss='modal'><i class='fa fa-paper-plane'></i>SEND COMMENT</button>

                                              </div>
                                            </div>

                                          </div>
                                        </div>
                                </td>
                                <td>
                                    <button type='button' class='btn btn-success' data-toggle='modal' data-target='#rectified_process'><i class='fa fa-cog fa-spin'></i>RECTIFIED</button>
                                        <div id='rectified_process' class='modal fade' role='dialog'>
                                          <div class='modal-dialog'>
                                            <div class='modal-content'>
                                              <div class='modal-header'>
                                                <button type='button'class='close' data-dismiss='modal'>&times;</button>
                                                <h4 class='modal-title'>RECTIFIED PROCESS</h4>
                                              </div>
                                              <div class='modal-body'>
                                                <input type='text' placeholder='INSERT COMMENT' class='form-control'>
                                              </div>
                                              <div class='modal-footer'>
                                                <button type='button' class='btn btn-success' data-dismiss='modal'><i class='fa fa-paper-plane'></i>SEND COMMENT</button>

                                              </div>
                                            </div>

                                          </div>
                                        </div>
                                </td>
                                <td>
                                     <button type='button' class='btn btn-danger' data-toggle='modal' data-target='#machined_process'><i class='fa fa-cog fa-spin'></i>MACHINED</button>
                                        <div id='machined_process' class='modal fade' role='dialog'>
                                          <div class='modal-dialog'>
                                            <div class='modal-content'>
                                              <div class='modal-header'>
                                                <button type='button'class='close' data-dismiss='modal'>&times;</button>
                                                <h4 class='modal-title'>MACHINED PROCESS</h4>
                                              </div>
                                              <div class='modal-body'>
                                                <input type='text' placeholder='INSERT COMMENT' class='form-control'>
                                              </div>
                                              <div class='modal-footer'>
                                                <button type='button' class='btn btn-success' data-dismiss='modal'><i class='fa fa-paper-plane'></i>SEND COMMENT</button>

                                              </div>
                                            </div>

                                          </div>
                                        </div>
                                </td>
                                <td>" . $finished . "</td>
                                <td>" .  $idprueba . "</td>
                            </tr>");    

                }
            ?>

1 个答案:

答案 0 :(得分:0)

我认为您应该在页面内直接编写HTML代码,避免PHP回显功能。

在此示例中,仅在需要时使用PHP短标记:

<tr id="row<?=$idtimeleft?>">

当您需要执行某些操作时,只需打开PHP标记并编写代码即可。

<select>
<?php
$query='SELECT nombre FROM metlab.supervisores';
$result1=mysql_query($query);
while($row1=mysql_fetch_array($result1)):
?>
<option><?=$row1[0]?></option>
<?php endwhile;?>
</select>    

“while(...):”之后你不需要分号。

无论如何,您应该阅读有关Twig的内容,以使用模板引擎编写更清晰的代码。 再见!!