Php 如何第一次检索数据
有人能告诉我如何在PHP中创建gridview,以及如何用数据库中的数据填充它吗?您可以使用 示例可在上找到 它使用方便,看起来很漂亮Php 如何第一次检索数据,php,mysql,Php,Mysql,有人能告诉我如何在PHP中创建gridview,以及如何用数据库中的数据填充它吗?您可以使用 示例可在上找到 它使用方便,看起来很漂亮 对于“从数据库获取数据”检查,我在共享给我的代码中找到了一种方法,可以用数据库中的数据填充表格,我可以编辑和编辑代码,并在表格中添加一列 部分代码如下所示: $sql= "SELECT a.id,a.apaterno,a.amaterno,a.nombres,a.fingreso,a.status,c.descripcion,b.nombre,a.fnacim
对于“从数据库获取数据”检查,我在共享给我的代码中找到了一种方法,可以用数据库中的数据填充表格,我可以编辑和编辑代码,并在表格中添加一列 部分代码如下所示:
$sql= "SELECT a.id,a.apaterno,a.amaterno,a.nombres,a.fingreso,a.status,c.descripcion,b.nombre,a.fnacimiento FROM templeados a,tunidades b,tpuestos c where a.idunidad='".$un[0]."' and a.status='A' and a.idunidad=b.iniciales and a.puesto=c.clave order by a.idunidad,a.apaterno";
$res=consulta($sql,$link);
$cuan=cuantos($res);
if($cuan==0){echo "<div class='error'>No hay empleados activos en la unidad ".$un[1]."!</div>";}else{
?>
<script type="text/javascript">
function valida(){
chec=document.getElementsByName("idemp");var res="Debes marcar el empleado";
for(var i=0; i<chec.length; i++){if(chec[i].checked==true){res="ok";}}
if(res=='ok'){
return true;
}else{alert(res); return false;}
}
</script>
<?php
echo '<div class="inst">Selecciona al empleado del que deseas ver su historia:</div>
<form id="form1" name="form1" method="post" action="historial.php" onsubmit="return valida();">';
echo "<table><caption>Empleados Activos Registrados en la Unidad ".$un[1]."</caption><thead><tr><thead><th scope='col'>Select</th><th scope='col'>Id</th><th scope='col'>Apellido Paterno</th><th scope='col'>Apellido Materno</th><th scope='col'>Nombre(s)</th><th scope='col'>Fecha Ingreso</th><th scope='col'>Status</th><th scope='col'>Puesto</th><th scope='col'>Unidad</th><th scope='col'>Fnacimiento</th></tr></thead><tbody style='text-align:left;'>";
$par=0;
while($row=resul_arreglo($res)){
echo "<tr";
if($par==0){echo ">";$par=1;}else{echo " class='par'>";$par=0;}
echo "<td><input type='radio' name='idemp' id='idemp' value='".$row[0]."'/></td><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td><td>".fecha_normal($row[4])."</td><td>";
echo ($row[5]=="A")?"Activo":"Inactivo";
echo "</td><td>".$row[6]."</td><td>".$row[7]."</td> <td>".$row[8]."</td> </tr>";
}
echo "</tbody><tfoot><tr><td>Select</td><td>Id</td><td>Apellido Patertno</td><td>Apellido Materno</td><td>Nombre(s)</td><td>Fecha Ingreso</td><td>Status</td><td>Puesto</td><td>Unidad</td><td>Unidad</td></tr></tfoot></table>";
echo '<div class="centrado"><input type="submit" name="Ver" id="Ver" value="Ver Historial" class="boton" /></div></form><br />';
}
}else{echo '<div class="error">Error en los datos no se puede procesar</div>';}
}else{
?>
现在我需要添加一个按钮导出到Excel
我不知道该怎么做。
在c语言中有一个类,很容易做到这一点
提前感谢您的帮助。分享您的研究成果对每个人都有帮助。告诉我们您尝试了什么,以及为什么它不能满足您的需求。这表明你花了时间来帮助自己,它使我们避免重复显而易见的答案,最重要的是,它帮助你得到一个更具体和相关的答案!另请看:太好了,我将尝试这个答案。
$sql= "SELECT a.id,a.apaterno,a.amaterno,a.nombres,a.fingreso,a.status,c.descripcion,b.nombre,a.fnacimiento FROM templeados a,tunidades b,tpuestos c where a.idunidad='".$un[0]."' and a.status='A' and a.idunidad=b.iniciales and a.puesto=c.clave order by a.idunidad,a.apaterno";
$res=consulta($sql,$link);
$cuan=cuantos($res);
if($cuan==0){echo "<div class='error'>No hay empleados activos en la unidad ".$un[1]."!</div>";}else{
?>
<script type="text/javascript">
function valida(){
chec=document.getElementsByName("idemp");var res="Debes marcar el empleado";
for(var i=0; i<chec.length; i++){if(chec[i].checked==true){res="ok";}}
if(res=='ok'){
return true;
}else{alert(res); return false;}
}
</script>
<?php
echo '<div class="inst">Selecciona al empleado del que deseas ver su historia:</div>
<form id="form1" name="form1" method="post" action="historial.php" onsubmit="return valida();">';
echo "<table><caption>Empleados Activos Registrados en la Unidad ".$un[1]."</caption><thead><tr><thead><th scope='col'>Select</th><th scope='col'>Id</th><th scope='col'>Apellido Paterno</th><th scope='col'>Apellido Materno</th><th scope='col'>Nombre(s)</th><th scope='col'>Fecha Ingreso</th><th scope='col'>Status</th><th scope='col'>Puesto</th><th scope='col'>Unidad</th><th scope='col'>Fnacimiento</th></tr></thead><tbody style='text-align:left;'>";
$par=0;
while($row=resul_arreglo($res)){
echo "<tr";
if($par==0){echo ">";$par=1;}else{echo " class='par'>";$par=0;}
echo "<td><input type='radio' name='idemp' id='idemp' value='".$row[0]."'/></td><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td><td>".fecha_normal($row[4])."</td><td>";
echo ($row[5]=="A")?"Activo":"Inactivo";
echo "</td><td>".$row[6]."</td><td>".$row[7]."</td> <td>".$row[8]."</td> </tr>";
}
echo "</tbody><tfoot><tr><td>Select</td><td>Id</td><td>Apellido Patertno</td><td>Apellido Materno</td><td>Nombre(s)</td><td>Fecha Ingreso</td><td>Status</td><td>Puesto</td><td>Unidad</td><td>Unidad</td></tr></tfoot></table>";
echo '<div class="centrado"><input type="submit" name="Ver" id="Ver" value="Ver Historial" class="boton" /></div></form><br />';
}
}else{echo '<div class="error">Error en los datos no se puede procesar</div>';}
}else{
?>