amigasos .. primero que nada agradecerles por toda la ayuda que me han dado para aprender y realizar lo que necesito
cada ves que algo me queda grande lo investigo y si veo una complicacion lo pregunto aki y me solucionan el problema de una patada .. XD
Código PHP:
<?php
//Exportar datos de php a Excel
header("Content-Type: application/vnd.ms-excel");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename=Reporte_matematicas.xls");
?>
<HTML LANG="es">
<TITLE>::. Exportacion de Datos .::</TITLE>
</head>
<body>
<?php
$cod = $_GET["cod"];
echo "$cod";
?>
<?php
$NombreBD = "a7845225_test";
$Servidor = "mysql10.000webhost.com";
$Usuario = "a7845225_root";
$Password ="1qa2ws";
$IdConexion = mysql_connect($Servidor, $Usuario, $Password);
mysql_select_db($NombreBD, $IdConexion);
$sql = "SELECT id, rut, codt, nombre, apellido, codigof, ciudad, fecha, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, r29, r30, r31, r32, r33, r34, r35, r36, r37, r38, r39, r40, r41, r42, r43, r44, r45, r46, r47, r48, r49, r50 FROM testm";
$result=mysql_query($sql,$IdConexion);
?>
<TABLE BORDER=1 align="center" CELLPADDING=1 CELLSPACING=1>
<TR>
<TD>id</TD>
<TD>rut</TD>
<TD>codt</TD>
<TD>nombre</TD>
<TD>apellido</TD>
<TD>codigof</TD>
<TD>ciudad</TD>
<TD>fecha</TD>
<TD>r1</TD>
<TD>r2</TD>
<TD>r3</TD>
<TD>r4</TD>
<TD>r5</TD>
<TD>r6</TD>
<TD>r7</TD>
<TD>r8</TD>
<TD>r9</TD>
<TD>r10</TD>
<TD>r11</TD>
<TD>r12</TD>
<TD>r13</TD>
<TD>r14</TD>
<TD>r15</TD>
<TD>r16</TD>
<TD>r17</TD>
<TD>r18</TD>
<TD>r19</TD>
<TD>r20</TD>
<TD>r21</TD>
<TD>r22</TD>
<TD>r23</TD>
<TD>r24</TD>
<TD>r25</TD>
<TD>r26</TD>
<TD>r27</TD>
<TD>r28</TD>
<TD>r29</TD>
<TD>r30</TD>
<TD>r31</TD>
<TD>r32</TD>
<TD>r33</TD>
<TD>r34</TD>
<TD>r35</TD>
<TD>r36</TD>
<TD>r37</TD>
<TD>r38</TD>
<TD>r39</TD>
<TD>r40</TD>
<TD>r41</TD>
<TD>r42</TD>
<TD>r43</TD>
<TD>r44</TD>
<TD>r45</TD>
<TD>r46</TD>
<TD>r47</TD>
<TD>r48</TD>
<TD>r49</TD>
<TD>r50</TD>
</TR>
<?php
while($row = mysql_fetch_array($result)) {
printf("<tr>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
<td> %s</td>
</tr>", $row["id"],$row["rut"],$row["codt"],$row["nombre"],$row["apellido"],$row["codigof"],$row["ciudad"],$row["fecha"],$row["r1"],$row["r2"],$row["r3"],$row["r4"],$row["r5"],$row["r6"],$row["r7"],$row["r8"],$row["r9"],$row["r10"],$row["r11"],$row["r12"],$row["r13"],$row["r14"],$row["r15"],$row["r16"],$row["r17"],$row["r18"],$row["r19"],$row["r20"],$row["r21"],$row["r22"],$row["r23"],$row["r24"],$row["r25"],$row["r26"],$row["r27"],$row["r28"],$row["r29"],$row["r30"],$row["r31"],$row["r32"],$row["r33"],$row["r34"],$row["r35"],$row["r36"],$row["r37"],$row["r38"],$row["r39"],$row["r40"],$row["r41"],$row["r42"],$row["r43"],$row["r44"],$row["r45"],$row["r46"],$row["r47"],$row["r48"],$row["r49"],$row["r50"]);
}
mysql_free_result($result);
mysql_close($IdConexion); //Cierras la Conexión
?>
</table>
<script language="Javascript">
document.oncontextmenu = function(){return false};
</script>
</body>
</html>
actualemte me funciona bien .. es decir me exporta a excel toda la tabla con todos los datos ..
LA IDEA ES ... en el siguiente
Código PHP:
<?php
include_once "conexion.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<script languaje="javascript">
function validar(){
if(form1.cod.value==''){
alert('ingrese un codigo valido');
form1.cod.focus();
return false;
}
if(form1.rut.value==''){
alert('ingrese un rut');
form1.rut.focus();
return false;
}
}
</script>
<script>
function validarNro(e) {
var key;
if(window.event) // IE
{
key = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
key = e.which;
}
if (key < 48 || key > 57)
{
if(key == 46 || key == 8) // Detectar . (punto) y backspace (retroceso)
{ return true; }
else
{ return false; }
}
return true;
}
</script>
</head>
<body>
<form method="post" id="form1" name="form1" form action="" class="login" onsubmit="return validar();"/>
<p><img src="portada1.jpg" alt="" width="1100" height="200" align="top" /></p>
<p> </p>
<table width="1100" border="0">
<tr>
<td colspan="2" align="center"><p><strong>INGRESE LOS DATOS SOLICITADOS</strong></p>
<p><?php
function verificar_codigo($cod,&$result)
{ $sql = "SELECT * FROM codigo WHERE cod = '$cod' ";
$rec = mysql_query($sql);
$count = 0;
while($row = mysql_fetch_object($rec))
{ $count++;
$result = $row;
}
if($count == 1)
{ return 1;
}
else
{ return 0;
}
}
//{
if(isset($_POST['login']))
{ if(verificar_codigo($_POST['cod'],$result) == 0)
{ echo 'El codigo no existe';
}
else
{ $cod = $_POST['cod'];
$rut = $_POST['rut'];
header("location:exportm.php?cod=$cod");
}
}
?>
</p></td>
</tr>
<tr>
<td width="491" align="right"><p><strong>Codigo:</strong></p></td>
<td width="599" align="left"><p>
<input name="cod" type="text" value="" maxlength="10" />
</p></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="login" type="submit" value="Exportar" /></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p><img src="divisor1.png" width="1100" height="10" alt="" /></p>
<p> </p>
<p> </p>
<script language="Javascript">
document.oncontextmenu = function(){return false};
</script>
</body>
</html>
mandar el codigo al php que me exporta .. y solo me exporte los iguales al codigo ... supongo que hay que trabajr en el que me exporta a excel .. tomar el codigo de estoy enviando y hacer la consulta .. pero no me funciona de ningun modo ..
ayuda