Código HTML:
<? //Funcion que lee un archivo de texto y lo mete en una cadena function leef ($fichero) { $texto = file($fichero); $tamleef = sizeof($texto); for ($n=0;$n<$tamleef;$n++) {$todo= $todo.$texto[$n];} return $todo; } //funcion que genera un rtf function rtf($sql, $plantilla, $fsalida, $matequivalencias){//funcion $pre=time(); $fsalida="C:/rtf/prueba/".$pre.$fsalida; mssql_connect("172.16.20.22","guty","guty-31-03-06"); //Paso no 1.-Leo una plantilla rtf $txtplantilla = leef($plantilla); //Paso no.2 Saca cabecera, el cuerpo y el final $matriz=explode("sectd", $txtplantilla); $cabecera=$matriz[0]."sectd"; $inicio=strlen($cabecera); $final=strrpos($txtplantilla,"}"); $largo=$final-$inicio; $cuerpo=substr($txtplantilla, $inicio, $largo); //Paso no.3 Escribo el fichero $punt = fopen($fsalida, "w"); fputs($punt, $cabecera); mssql_select_db("Presidencia"); $result =mssql_query($sql); while($row=mssql_fetch_object($result)){//while $despues=$cuerpo; foreach ($matequivalencias as $dato) { //foreach $datosql=$row->$dato[1]; $datosql= stripslashes ($datosql); $datortf=$dato[0]; $despues=str_replace($datortf,$datosql,$despues); } }//while fputs($punt,$despues); $saltopag="\par \page \par"; fputs($punt,$saltopag); //} fputs($punt,"}"); fclose ($punt); return $fsalida; }//funcion $plantilla = "C:/rtf/plantilla.rtf"; $sql = "SELECT * FROM RECADOS_TEL WHERE DIA=7 AND MES=2 AND ANO=2008 ORDER BY ID_RECTEL DESC"; $equivalencias[1][0]="#*NOMBRE*#"; $equivalencias[1][1]="NOMBRE"; $equivalencias[2][0]="#*ANO*#"; $equivalencias[2][1]="ANO"; $equivalencias[3][0]="#*TELEFONO1*#"; $equivalencias[3][1]="TELEFONO1"; $equivalencias[4][0]="#*DIA*#"; $equivalencias[4][1]="DIA"; $equivalencias[5][0]="#*MES*#"; $equivalencias[5][1]="MES"; $salida = rtf($sql, $plantilla, "genera.rtf", $equivalencias); $salida ="<A href='$salida'>Obtener RTF</a>"; echo "<p>$salida</p>"; ?>
![ojotes](http://static.forosdelweb.com/fdwtheme/images/smilies/ojotes.png)
![Neurótico](http://static.forosdelweb.com/fdwtheme/images/smilies/scared.png)
![Adios](http://static.forosdelweb.com/fdwtheme/images/smilies/adios.gif)
Ayuda por favor..................................
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
Nadie sabe como resolver esto?.............................
![Neurótico](http://static.forosdelweb.com/fdwtheme/images/smilies/scared.png)