elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  ayuda con codigo php
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: ayuda con codigo php  (Leído 1,495 veces)
Dannysoft


Desconectado Desconectado

Mensajes: 410


¡¡ Al Asalto !!


Ver Perfil
ayuda con codigo php
« en: 30 Julio 2008, 16:03 pm »

saludos foro tengo una consulta que hacerles, bueno tengo un pequeño sistema de noticias en php, todo funciona bien, solo que me piden hacer esto, las noticias van acompañadas de un pdf que se ve cuando alguien hace clic en el titulo de la noticia se habre en otra ventana y ahi se ve el pdf, los cuales se guardan en una carpeta pdf_soporte, ya he programado un php para subir los pdf desde la pc, pero no logro indicarle al php que cuando hagan clic en el titulo se habra el pdf que le corresponde, mi idea es usar los id de las noticias pero hasta ahi llego, mi pregunta es como puedo hacer eso, gracias por la ayuda que me den


« Última modificación: 30 Julio 2008, 16:07 pm por Dannysoft » En línea

No hay perfeccion sin esfuerzo...
Dannysoft


Desconectado Desconectado

Mensajes: 410


¡¡ Al Asalto !!


Ver Perfil
Re: ayuda con codigo php
« Respuesta #1 en: 30 Julio 2008, 16:04 pm »

el codigo de mi bd  es este:
Código
  1. # phpMyAdmin MySQL-Dump
  2. # version 2.2.5
  3. # http://phpwizard.net/phpMyAdmin/
  4. # http://phpmyadmin.sourceforge.net/ (download page)
  5. #
  6. # servidor: localhost
  7. # Tiempo de Generacion: 27-08-2007 a les 11:34:41
  8. # Version del Servidor: 3.23.47
  9. # Version del PHP: 4.1.1
  10. # Base De Datos : `ig`
  11. # --------------------------------------------------------
  12.  
  13. #
  14. # Estructura de tabla para tabla `soporte`
  15. #
  16.  
  17. CREATE TABLE soporte (
  18.  id INT(11) NOT NULL AUTO_INCREMENT,
  19.  titulo VARCHAR(150) NOT NULL DEFAULT '',
  20.  comentario text NOT NULL,
  21.  PRIMARY KEY  (id)
  22. ) TYPE=MyISAM;
  23.  
  24. #
  25. # Volcar la base de datos para la tabla `soporte`
  26. #
  27.  
  28. INSERT INTO soporte VALUES (1, 'Lanzamos nuestros nuevos productos', Avisamos a nuestros clientes la llegada de sus nuevos productos marca Extech.\r\n<br>\r\n<br>\r\nAsi es.\r\n');
  29. INSERT INTO soporte VALUES (2, 'Deltha OHM', 'La compañia delta...');
  30.  
  31.  



En línea

No hay perfeccion sin esfuerzo...
Dannysoft


Desconectado Desconectado

Mensajes: 410


¡¡ Al Asalto !!


Ver Perfil
Re: ayuda con codigo php
« Respuesta #2 en: 30 Julio 2008, 16:05 pm »

aver bueno este es mi archivo php que uso para mostrar mi informacion, bueno para programar esto uso el ultradev 4

ig_nuevos_productos.php
Código
  1. <?php
  2.  
  3. //    Copyright (c) Interakt Online 2001
  4.  //    http://www.interakt.ro/
  5.  
  6.  
  7.  require("./adodb/adodb.inc.php");
  8.  require("./Connections/cnSoporte.php");
  9. ?><?php
  10.   $rs=$cnSoporte->Execute("SELECT * FROM soporte") or DIE($cnSoporte->ErrorMsg());
  11.   $rs_numRows=0;
  12.   $rs__totalRows=$rs->RecordCount();
  13. ?><?php
  14.  
  15.  //    Copyright (c) Interakt Online 2001
  16.  //    http://www.interakt.ro/
  17.  
  18.  require("./adodb/adodb.inc.php");
  19.  require("./Connections/cnSoporte.php");
  20. ?><?php
  21.   $rs=$cnSoporte->Execute("SELECT * FROM soporte") or DIE($cnSoporte->ErrorMsg());
  22.   $rs_numRows=0;
  23.   $rs__totalRows=$rs->RecordCount();
  24. ?><?php
  25.  
  26.  
  27.  //    Copyright (c) Interakt Online 2001
  28.  //    http://www.interakt.ro/
  29.  
  30.  require("./adodb/adodb.inc.php");
  31.  require("./Connections/cnSoporte.php");
  32. ?><?php
  33.   $rs=$cnSoporte->Execute("SELECT * FROM soporte") or DIE($cnSoporte->ErrorMsg());
  34.   $rs_numRows=0;
  35.   $rs__totalRows=$rs->RecordCount();
  36. ?><?php
  37.   $Repeat1__numRows = -1;
  38.   $Repeat1__index= 0;
  39.   $rs_numRows = $rs_numRows + $Repeat1__numRows;
  40. ?><?php
  41.  // *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
  42.  
  43.  // set the record count
  44.  $rs_total = $rs->RecordCount();
  45.  
  46.  // set the number of rows displayed on this page
  47.  if ($rs_numRows < 0) {            // if repeat region set to all records
  48.    $rs_numRows = $rs_total;
  49.  } else if ($rs_numRows == 0) {    // if no repeat regions
  50.    $rs_numRows = 1;
  51.  }
  52.  
  53.  // set the first and last displayed record
  54.  $rs_first = 1;
  55.  $rs_last  = $rs_first + $rs_numRows - 1;
  56.  
  57.  // if we have the correct record count, check the other stats
  58.  if ($rs_total != -1) {
  59.    $rs_numRows = min($rs_numRows, $rs_total);
  60.    $rs_first  = min($rs_first, $rs_total);
  61.    $rs_last  = min($rs_last, $rs_total);
  62.  }
  63.  ?><?php $MM_paramName = ""; ?><?php
  64. // *** Move To Record and Go To Record: declare variables
  65.  
  66. $MM_rs      = &$rs;
  67. $MM_rsCount   = $rs_total;
  68. $MM_size      = $rs_numRows;
  69. $MM_uniqueCol = "id";
  70. $MM_paramName = "id";
  71. $MM_offset = 0;
  72. $MM_atTotal = false;
  73. $MM_paramIsDefined = ($MM_paramName != "" && isset($$MM_paramName));
  74. ?><?php
  75. // *** Move To Specific Record: handle detail parameter
  76.  
  77. if ($MM_paramIsDefined && $MM_rsCount != 0) {
  78.  
  79.  // get the value of the parameter
  80.  $param = $$MM_paramName;
  81.  
  82.  // find the record with the unique column value equal to the parameter value
  83.  for ($MM_offset=0; !$MM_rs->EOF; $MM_offset++) {
  84.    if ($MM_rs->Fields($MM_uniqueCol) == $param) break;
  85.    $MM_rs->MoveNext();
  86.  }
  87.  
  88.  // if not found, set the number of records and reset the cursor
  89.  if ($MM_rs->EOF) {
  90.    if ($MM_rsCount < 0) $MM_rsCount = $MM_offset;
  91.    if ($MM_size < 0 || $MM_size > $MM_rsCount) $MM_size = $MM_rsCount;
  92.    $MM_offset = 0;
  93.  
  94.    // reset the cursor to the beginning
  95.    $MM_rs->MoveFirst();
  96.  }
  97. }
  98. ?><?php
  99. // *** Move To Record: if we dont know the record count, check the display range
  100.  
  101. if ($MM_rsCount == -1) {
  102.  
  103.  // walk to the end of the display range for this page
  104.  for ($i=$MM_offset; !$MM_rs->EOF && ($MM_size < 0 || $i < $MM_offset + $MM_size); $i++) {
  105.    $MM_rs->MoveNext();
  106.  }
  107.  
  108.  // if we walked off the end of the recordset, set MM_rsCount and MM_size
  109.  if ($MM_rs->EOF) {
  110.    $MM_rsCount = $i;
  111.    if ($MM_size < 0 || $MM_size > $MM_rsCount) $MM_size = $MM_rsCount;
  112.  }
  113.  
  114.  // if we walked off the end, set the offset based on page size
  115.  if ($MM_rs->EOF && !$MM_paramIsDefined) {
  116.    if (($MM_rsCount % $MM_size) != 0) {  // last page not a full repeat region
  117.      $MM_offset = $MM_rsCount - ($MM_rsCount % $MM_size);
  118.    } else {
  119.      $MM_offset = $MM_rsCount - $MM_size;
  120.    }
  121.  }
  122.  
  123.  // reset the cursor to the beginning
  124.  $MM_rs->MoveFirst();
  125.  
  126.  // move the cursor to the selected record
  127.  for ($i=0; !$MM_rs->EOF && $i < $MM_offset; $i++) {
  128.    $MM_rs->MoveNext();
  129.  }
  130. }
  131. ?><?php
  132. // *** Move To Record: update recordset stats
  133.  
  134. // set the first and last displayed record
  135. $rs_first = $MM_offset + 1;
  136. $rs_last  = $MM_offset + $MM_size;
  137. if ($MM_rsCount != -1) {
  138.  $rs_first = $rs_first<$MM_rsCount?$rs_first:$MM_rsCount;
  139.  $rs_last  = $rs_last<$MM_rsCount?$rs_last:$MM_rsCount;
  140. }
  141.  
  142. // set the boolean used by hide region to check if we are on the last record
  143. $MM_atTotal = ($MM_rsCount != -1 && $MM_offset + $MM_size >= $MM_rsCount);
  144. ?>
  145. <html>
  146. <head>
  147. <title>Untitled Document</title>
  148. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  149. <link rel="stylesheet" href="estilo_noticias.css" type="text/css">
  150. <style type="text/css">
  151. <!--
  152. body {
  153.    margin-left: 0px;
  154.    margin-top: 0px;
  155.    margin-right: 0px;
  156.    margin-bottom: 0px;
  157. }
  158. -->
  159. </style>
  160. </head>
  161. <body bgcolor="#FFFFFF" text="#000000">
  162. <table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
  163.  <tr>  
  164.    <th colspan="3" valign="top" scope="col">  
  165.      <?include("superior.htm")?>
  166.    </th>
  167.  </tr>
  168.  <tr>  
  169.    <td width="140" valign="top" bgcolor="#FFDF9D">  
  170.      <?include("izquierda.htm")?>
  171.    </td>
  172.    <td width="480" valign="top" bgcolor="#FFFFFF">  
  173.      <table width="460" border="0" align="center" cellspacing="0" cellpadding="0">
  174.        <tr>  
  175.          <td class="texto_titulo" colspan="2">  
  176.            <table border="0" cellpadding="0" cellspacing="0" width="436">
  177.              <!-- fwtable fwsrc="titulo.png" fwbase="titulo.jpg" fwstyle="Dreamweaver" fwdocid = "694147630" fwnested="0" -->
  178.              <tr>  
  179.                <td><img src="img/spacer.gif" width="2" height="1" border="0" alt="" /></td>
  180.                <td><img src="img/spacer.gif" width="396" height="1" border="0" alt="" /></td>
  181.                <td><img src="img/spacer.gif" width="38" height="1" border="0" alt="" /></td>
  182.                <td><img src="img/spacer.gif" width="1" height="1" border="0" alt="" /></td>
  183.              </tr>
  184.              <tr>  
  185.                <td colspan="3"><img name="titulo_r1_c1" src="img/titulo_r1_c1.jpg" width="436" height="3" border="0" id="titulo_r1_c1" alt="" /></td>
  186.                <td><img src="img/spacer.gif" width="1" height="3" border="0" alt="" /></td>
  187.              </tr>
  188.              <tr>  
  189.                <td rowspan="2"><img name="titulo_r2_c1" src="img/titulo_r2_c1.jpg" width="2" height="27" border="0" id="titulo_r2_c1" alt="" /></td>
  190.                <td background="img/titulo_r2_c2.jpg"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="396" height="25">
  191.                    <param name="movie" value="flash/ig_nuevos_productos.swf">
  192.                    <param name="quality" value="high">
  193.                    <param name="wmode" value="transparent">
  194.                    <embed src="flash/ig_nuevos_productos.swf" width="396" height="25" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent">
  195.                    </embed>  
  196.                  </object></td>
  197.                <td rowspan="2"><img name="titulo_r2_c3" src="img/titulo_r2_c3.jpg" width="38" height="27" border="0" id="titulo_r2_c3" alt="" /></td>
  198.                <td><img src="img/spacer.gif" width="1" height="25" border="0" alt="" /></td>
  199.              </tr>
  200.              <tr>  
  201.                <td><img name="titulo_r3_c2" src="img/titulo_r3_c2.jpg" width="396" height="2" border="0" id="titulo_r3_c2" alt="" /></td>
  202.                <td><img src="img/spacer.gif" width="1" height="2" border="0" alt="" /></td>
  203.              </tr>
  204.            </table>
  205.          </td>
  206.        </tr>
  207.        <tr>  
  208.          <td class="texto_titulo">&nbsp;</td>
  209.          <td class="texto_titulo" valign="top">&nbsp; </td>
  210.        </tr>
  211.        <tr>  
  212.          <td colspan="2">  
  213.            <?php while (($Repeat1__numRows-- != 0) && (!$rs->EOF))  
  214.   {  
  215. ?>
  216.            <table width="460" border="0" cellspacing="0" cellpadding="0">
  217.              <tr>  
  218.                <td width="120"><img src="fotos_soporte/<?php echo $rs->Fields("id")?>.jpg" width="100" height="100"></td>
  219.                <td valign="top" width="340"><a href="pdf_soporte/<?php echo $rs-Fields("id")?>.pdf"><?php echo $rs->Fields("titulo")?></a><br />
  220.  
  221.                  <span class="texto_comentario">  
  222.                  <?php echo $rs->Fields("comentario")?>
  223.                  </span></td>
  224.              </tr>
  225.              <tr>  
  226.                <td>&nbsp;</td>
  227.                <td>&nbsp;</td>
  228.              </tr>
  229.              <tr>  
  230.                <td colspan="2">  
  231.                  <hr>
  232.                </td>
  233.              </tr>
  234.            </table>
  235.            <?php
  236.  $Repeat1__index++;
  237.  $rs->MoveNext();
  238. }
  239. ?>
  240.          </td>
  241.        </tr>
  242.      </table>
  243.      <p align="center">&nbsp;</p>
  244.      <p align="right"><a href="javascript:window.history.back()"><span class="texto_comentario">&gt;&gt;  
  245.        Regresar</span></a><br>
  246.      </p>
  247.    </td>
  248.    <td width="140" valign="top" bgcolor="#FFDF9D">  
  249.      <?include("derecha.htm")?>
  250.    </td>
  251.  </tr>
  252.  <tr>  
  253.    <td colspan="3" valign="top" bgcolor="#FFFFFF">  
  254.      <?include("base.htm")?>
  255.    </td>
  256.  </tr>
  257. </table>
  258. </body>
  259. </html>
  260. <?php
  261.  $rs->Close();
  262. ?>
  263. <?php
  264.  $rs->Close();
  265. ?>
  266. <?php
  267.  $rs->Close();
  268. ?>
  269.  
En línea

No hay perfeccion sin esfuerzo...
Dannysoft


Desconectado Desconectado

Mensajes: 410


¡¡ Al Asalto !!


Ver Perfil
Re: ayuda con codigo php
« Respuesta #3 en: 30 Julio 2008, 16:06 pm »

y el archivo para subir mis pdf es este:

subir_pdf.php
Código
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>::: Subir PDF  ::</title>
  6. <link rel="stylesheet" href="estilo_deportes.css" type="text/css">
  7. <link rel="stylesheet" href="estilo_noticias.css" type="text/css">
  8. </head>
  9.  
  10. <body bgcolor="#FFFFFF">
  11. <p class="texto_titulo">Subir Archivos PDF::</p>
  12. <ol>
  13.  <li><span class="texto_titulo">Nota:</span><br>
  14.    <span class="texto_comentario">para subir pdf tener en cuenta el numero  
  15.    de IP noticia, ejemplo: si e IPnoticia es 1, el PDF debe llamarse 1.pdf</span></li>
  16. </ol>
  17. <p>
  18.  <?php
  19. if ($enviar) {
  20. move_uploaded_file($archivo,"pdf_soporte/$archivo_name");
  21. $url = "pdf_soporte/".$archivo_name;
  22. chmod($url,0777);
  23. echo "PDF subido exitosamente";  
  24. }
  25. else {
  26. ?>
  27. </p>
  28. <Form method="post" action="subir_pdf.php" enctype="multipart/form-data">  
  29.  <input type="file" name="archivo">
  30.  <br>
  31.  <input name="enviar" type="submit">
  32.  <?php
  33. }
  34. ?>
  35.  
  36. </body>
  37. </html>
  38.  
En línea

No hay perfeccion sin esfuerzo...
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines