Estyoy haciendo un archivo en excel. y me sale este error :
Cita:
Esto lo probe con un ejemplo y funciono pero ahroa que lo converti en el formato para exportar me sale ese error del WHILE. pero por mas que trato no doy en la solucionParse error: syntax error, unexpected T_WHILE in /home/clinte14/public_html/admin/exportarclasif_empresas.php on line 34
Código PHP:
<?
require_once('../conex/conectardatabase.inc.php') ;
$consulta = mysql_query ("SELECT DISTINCT nombre , id_categoria FROM `categoria` ", $dbh) or die (mysql_error());
$shtml="<table > ";
$shtml=$shtml." <tr>";
$shtml=$shtml." <td>idCategoria</td>";
$shtml=$shtml." <td>Nombre Categoria </td>";
$shtml=$shtml." </tr>";
while($cat_empresa = mysql_fetch_array($consulta))
{
$idtablacategoria = $cat_empresa['id_categoria'];
$shtml=$shtml." <tr>";
$shtml=$shtml." <td>".$cat_empresa['id_categoria']."</td>";
$shtml=$shtml." <td>".$cat_empresa['nombre']."</td>";
$shtml=$shtml." </tr>";
$shtml=$shtml." <tr>";
$shtml=$shtml." <td> </td>";
$shtml=$shtml." <td><table cellpadding=\"1\" cellspacing=\"1\">";
/*
Consulta de las emrpesas tomando como condicion la variable idtablacategoria
*/
$consultaempresa = mysql_query ("SELECT cat_empresa.id_categoria, cat_empresa.id_empresa,
empresa.id_empresa, empresa.razonsocial,empresa.direccion,
empresa.distrito,empresa.telefono,empresa.fax,empresa.email,
empresa.website,empresa.giro
FROM cat_empresa
INNER JOIN empresa ON cat_empresa.id_empresa = empresa.id_empresa
WHERE cat_empresa.id_categoria = '$idtablacategoria' ", $dbh)
while($row_empresa = mysql_fetch_array($consultaempresa)) or die (mysql_error());
{
$shtml=$shtml." <tr>";
$shtml=$shtml." <td >idcategoria</td>";
$shtml=$shtml." <td >".$row_empresa['id_categoria']."</td>";
$shtml=$shtml." </tr>";
$shtml=$shtml." <tr>";
$shtml=$shtml." <td>idempresa</td>";
$shtml=$shtml." <td>".$row_empresa['id_empresa']."</td>";
$shtml=$shtml." </tr>";
$shtml=$shtml." <tr>";
$shtml=$shtml." <td>Empresa</td>";
$shtml=$shtml." <td>".$row_empresa['razonsocial']."</td>";
$shtml=$shtml." </tr>";
$shtml=$shtml." <tr>";
$shtml=$shtml." <td>Direccion</td>";
$shtml=$shtml." <td>".$row_empresa['direccion']."</td>";
$shtml=$shtml." </tr>";
$shtml=$shtml." <tr>";
$shtml=$shtml." <td>Distrito</td>";
$shtml=$shtml." <td>".$row_empresa['distrito']."</td>";
$shtml=$shtml." </tr>";
$shtml=$shtml." <tr>";
$shtml=$shtml." <td>Telefono</td>";
$shtml=$shtml." <td>".$row_empresa['telefono']."</td>";
$shtml=$shtml." </tr>";
$shtml=$shtml." <tr>";
$shtml=$shtml." <td >Fax</td>";
$shtml=$shtml." <td >".$row_empresa['fax']."</td>";
$shtml=$shtml." </tr>";
$shtml=$shtml." <tr>";
$shtml=$shtml." <td>Email</td>";
$shtml=$shtml." <td>".$row_empresa['email']."</td>";
$shtml=$shtml." </tr>";
$shtml=$shtml." <tr>";
$shtml=$shtml." <td>Web Site</td>";
$shtml=$shtml." <td>".$row_empresa['website']."</td>";
$shtml=$shtml." </tr>";
$shtml=$shtml." <tr>";
$shtml=$shtml." <td>Giro</td>";
$shtml=$shtml." <td>".$row_empresa['giro']."</td>";
$shtml=$shtml." </tr> ";
mysql_free_result($consultaempresa);
$shtml=$shtml." </table></td>";
$shtml=$shtml." </tr> ";
}
}
mysql_free_result($consulta);
$shtml.="</table>";
$scarpetaguardar="excel/"; //carpeta donde guardar el archivo.
$enlaceclaf_emppresa=$scarpetaguardar."clasificados_empresas.xls"; //ruta del archivo a generar
$fpt=fopen($enlaceclaf_emppresa,"w");
fwrite($fpt,$shtml);
fclose($fpt);
?>