放入多个动态下拉列表

时间:2017-06-16 17:01:42

标签: php html mysqli

<?php 
$link=mysqli_connect("localhost","root","usbw");
mysqli_select_db($link,"inventario");
?>

<script>
    // Define JavaScript Global Var
    window.pageRef =  'computadora';
</script>
<?php
header('Content-type:text/html;charset=ISO-8859-15');
$dbname='inventario';
$user='root';
$pasword='usbw';
$dbhost='localhost:3307';

$con= mysql_connect($dbhost,$user,$pasword,$dbname);
if(! $con){
    die('No se puede conectar'.mysql_error);
    }
    $sql="SELECT * FROM computadora";
    mysql_select_db($dbname);//selecionar la base de dato
    $result=mysql_query($sql,$con);

    if(!$result){//verifica si hay algo en la base de dato
        echo 'No existen datos.';
    }
    else{
       echo' <div class="panel panel-default">';

echo '<div class="panel-heading">Computadora </div>';
        echo'<table class="table">';
        echo'<tr>';
        echo '<th>Computadora</th>';
        echo'<th>idos</th>';
        echo"<th>idstatus</th>";
        echo"<th>fechacompra</th>";
        echo"<th>idmarca</th>";
        echo"<th>idmodelo</th>";
        //echo"<th>idoficina</th>";
        echo"<th>idempleado</th>";
        echo"<th>Service Tag</th>";
        echo"<th>Numero Propiedad</th>";
        echo"<th>Comentario</th>";
        echo '<th>';
        echo '<button id="btnNew" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#modalWindowNewRec">';
       echo '<span class="glyphicon glyphicon-plus"></span>';
       echo '&nbsp;A&ntilde;adir</button>';
        echo '</th>';
        echo'</tr>';
        while($row=mysql_fetch_array($result)){//esta consulta lo va a haser si hay datos en la base de datos en este caso 'oficina'
           echo '<tr id="r'. $row["computadora"] .'">';
            echo "<td id='idRec'> {$row['computadora']} </td>";

            echo "<td> {$row['idos']} </td>";
            echo"<td> {$row['idstatus']} </td>";
            echo "<td>{$row['fechacompra']}</td>";
            echo"<td>{$row['idmarca']}</td>";
            echo "<td>{$row['idmodelo']}</td>";
            //echo "<td>{$row['idoficina']}</td>";
            echo "<td>{$row['idempleado']}</td>";
            echo"<td>{$row['ServiceTag']}</td>";
            echo"<td>{$row['numpropiedad']}</td>";
            echo"<td>{$row['idcomentario']}</td>";
            echo'<td>';
           echo '<a href="#" id="edit"  data-toggle="modal" data-target="#modalWindowEditRec">';
           echo '<span class="glyphicon glyphicon-pencil btn btn-success  btn-xs">';
           echo '</span>'; 
              echo '</a>&nbsp;&nbsp;';
            echo '<a href="#" id="delete" data-toggle="modal" data-target="#modalWindowDelete">';
           echo '<span class="glyphicon glyphicon-remove btn btn-danger  btn-xs">';
           echo '</span>';           
           echo '</a>'; 
            echo'</td>';
            echo'</tr>';
        }
          echo '</table>';
       echo '</div>';
       echo '<div id="recActionMsg" class="alert"></div>'; 
    }
    mysql_close($con);




?>



<!-- Modal WINDOW DELETE RECORD -->
<div id="modalWindowDelete" class="modal fade" role="dialog">
  <div class="modal-dialog modal-sm">

    <!-- Modal content-->
    <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Borrar Fila</h4>
          </div>
          <div class="modal-body">
          <p>&iquest;Desea BORRAR la Fila?</p>
          </div>
          <div class="modal-footer ">
          <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>      
          <button type="button" class="btn btn-danger" data-dismiss="modal" id='borrarFila' >Borrar</button>
        </div>  
    </div>

  </div>
</div>


<!-- Modal WINDOW NEW RECORD -->
<div id="modalWindowNewRec" class="modal fade" role="dialog">
  <div class="modal-dialog modal-sm">

    <!-- Modal content-->
    <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">A&ntilde;adir Fila</h4>
          </div>
          <div class="modal-body">

            <form class='form' id='addRecForm'>
                <input type='text' class="form-control" name='computadora'id='computadora' placeholder='Computadora'>

                <input type='text' class="form-control" name='fechacompra'id='fechacompra' placeholder='fechacompra'>
                <input type='text' class="form-control" name='servicetag'id='servicetag' placeholder='Service Tag'>
                <input type='text' class="form-control" name='numpropiedad'id='numpropiedad' placeholder='Numero de Propiedad'>
                <input type='text' class="form-control" name='idos'id='idos' placeholder='Id operating system'>
                <input type='text' class="form-control" name='idmarca'id='idmarca' placeholder='IdMarca'>
                <input type='text' class="form-control" name='idstatus'id='idstatus' placeholder='IdStatus'>
                <input type='text' class="form-control" name='idmodelo'id='idmodelo' placeholder='IdModelo'>
               <!-- <input type='text' class="form-control" name='idempleado'id='idempleado' placeholder='IdEmpeado'>-->
<form name='form1'>
<table>
<tr>

<td><select name='idempleado'id='idempleado'>
<option>Empleado</option>
<?php
$res=mysqli_query($link,"SELECT * FROM empleado");
while($row=mysqli_fetch_array($res)){
?>
<option><?php echo $row["idempleado"];?>: <?php echo $row["nombre"];?></option>
<?php
}
?>
</select></td>
</tr>
</table>
</form>
               <!--aqui-->
                <!--<input type='text' class="form-control" name='idoficina'id='idoficina' placeholder='IdOficina'>-->

                <!--<input type='text' class="form-control" name='idcomentario'id='idcomentario' placeholder='IdComentario'>-->
                <form name='form2'>
<table>
<tr>

<td><select name='idcomentario'id='idcomentario'>
<option>Comentario</option>
<?php
$res=mysqli_query($link,"SELECT * FROM comentario");
while($row=mysqli_fetch_array($res)){
?>
<option><?php echo $row["idcomentario"];?>: <?php echo $row["comentario"];?></option>
<?php
}
?>
</select></td>
</tr>
</table>
</form>

            </form>

          </div>
          <div class="modal-footer ">
          <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>      
          <button type="button" class="btn btn-danger" data-dismiss="modal" id='insertarFila' >A&ntilde;adir</button>
        </div>  
    </div>

  </div>
</div>


<!-- Modal WINDOW EDIT RECORD -->
<div id="modalWindowEditRec" class="modal fade" role="dialog">
  <div class="modal-dialog modal-sm">

    <!-- Modal content-->
    <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Editar R&eacute;cord</h4>
          </div>
          <div class="modal-body">

            <form class='form'  id='editRecForm'>
                <input type='text' class="form-control" name='computadora-1' id='computadora-1' placeholder='Computadora'>
            </form>

          </div>
        <div class="modal-footer ">
          <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>      
          <button type="button" class="btn btn-danger" data-dismiss="modal" id='guardarFila' >Guardar</button>
        </div>  
    </div>

  </div>
</div>

上面的代码是我正在制作的程序的一部分,它的功能列出了数据库,然后可以更新该信息,读取并删除它。我的问题是它说“Form name ='form2'”我想放置多个动态下拉列表,以便用户更容易插入信息,但出于某种原因只有“form1”有效。

0 个答案:

没有答案