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
el codigo de mi bd es este:
# phpMyAdmin MySQL-Dump
# version 2.2.5
# http://phpwizard.net/phpMyAdmin/
# http://phpmyadmin.sourceforge.net/ (download page)
#
# servidor: localhost
# Tiempo de Generacion: 27-08-2007 a les 11:34:41
# Version del Servidor: 3.23.47
# Version del PHP: 4.1.1
# Base De Datos : `ig`
# --------------------------------------------------------
#
# Estructura de tabla para tabla `soporte`
#
CREATE TABLE soporte (
id int(11) NOT NULL auto_increment,
titulo varchar(150) NOT NULL default '',
comentario text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
#
# Volcar la base de datos para la tabla `soporte`
#
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');
INSERT INTO soporte VALUES (2, 'Deltha OHM', 'La compañia delta...');
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
<?php
// Copyright (c) Interakt Online 2001
// http://www.interakt.ro/
require("./adodb/adodb.inc.php");
require("./Connections/cnSoporte.php");
?><?php
$rs=$cnSoporte->Execute("SELECT * FROM soporte") or DIE($cnSoporte->ErrorMsg());
$rs_numRows=0;
$rs__totalRows=$rs->RecordCount();
?><?php
// Copyright (c) Interakt Online 2001
// http://www.interakt.ro/
require("./adodb/adodb.inc.php");
require("./Connections/cnSoporte.php");
?><?php
$rs=$cnSoporte->Execute("SELECT * FROM soporte") or DIE($cnSoporte->ErrorMsg());
$rs_numRows=0;
$rs__totalRows=$rs->RecordCount();
?><?php
// Copyright (c) Interakt Online 2001
// http://www.interakt.ro/
require("./adodb/adodb.inc.php");
require("./Connections/cnSoporte.php");
?><?php
$rs=$cnSoporte->Execute("SELECT * FROM soporte") or DIE($cnSoporte->ErrorMsg());
$rs_numRows=0;
$rs__totalRows=$rs->RecordCount();
?><?php
$Repeat1__numRows = -1;
$Repeat1__index= 0;
$rs_numRows = $rs_numRows + $Repeat1__numRows;
?><?php
// *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
// set the record count
$rs_total = $rs->RecordCount();
// set the number of rows displayed on this page
if ($rs_numRows < 0) { // if repeat region set to all records
$rs_numRows = $rs_total;
} else if ($rs_numRows == 0) { // if no repeat regions
$rs_numRows = 1;
}
// set the first and last displayed record
$rs_first = 1;
$rs_last = $rs_first + $rs_numRows - 1;
// if we have the correct record count, check the other stats
if ($rs_total != -1) {
$rs_numRows = min($rs_numRows, $rs_total);
$rs_first = min($rs_first, $rs_total);
$rs_last = min($rs_last, $rs_total);
}
?><?php $MM_paramName = ""; ?><?php
// *** Move To Record and Go To Record: declare variables
$MM_rs = &$rs;
$MM_rsCount = $rs_total;
$MM_size = $rs_numRows;
$MM_uniqueCol = "id";
$MM_paramName = "id";
$MM_offset = 0;
$MM_atTotal = false;
$MM_paramIsDefined = ($MM_paramName != "" && isset($$MM_paramName));
?><?php
// *** Move To Specific Record: handle detail parameter
if ($MM_paramIsDefined && $MM_rsCount != 0) {
// get the value of the parameter
$param = $$MM_paramName;
// find the record with the unique column value equal to the parameter value
for ($MM_offset=0; !$MM_rs->EOF; $MM_offset++) {
if ($MM_rs->Fields($MM_uniqueCol) == $param) break;
$MM_rs->MoveNext();
}
// if not found, set the number of records and reset the cursor
if ($MM_rs->EOF) {
if ($MM_rsCount < 0) $MM_rsCount = $MM_offset;
if ($MM_size < 0 || $MM_size > $MM_rsCount) $MM_size = $MM_rsCount;
$MM_offset = 0;
// reset the cursor to the beginning
$MM_rs->MoveFirst();
}
}
?><?php
// *** Move To Record: if we dont know the record count, check the display range
if ($MM_rsCount == -1) {
// walk to the end of the display range for this page
for ($i=$MM_offset; !$MM_rs->EOF && ($MM_size < 0 || $i < $MM_offset + $MM_size); $i++) {
$MM_rs->MoveNext();
}
// if we walked off the end of the recordset, set MM_rsCount and MM_size
if ($MM_rs->EOF) {
$MM_rsCount = $i;
if ($MM_size < 0 || $MM_size > $MM_rsCount) $MM_size = $MM_rsCount;
}
// if we walked off the end, set the offset based on page size
if ($MM_rs->EOF && !$MM_paramIsDefined) {
if (($MM_rsCount % $MM_size) != 0) { // last page not a full repeat region
$MM_offset = $MM_rsCount - ($MM_rsCount % $MM_size);
} else {
$MM_offset = $MM_rsCount - $MM_size;
}
}
// reset the cursor to the beginning
$MM_rs->MoveFirst();
// move the cursor to the selected record
for ($i=0; !$MM_rs->EOF && $i < $MM_offset; $i++) {
$MM_rs->MoveNext();
}
}
?><?php
// *** Move To Record: update recordset stats
// set the first and last displayed record
$rs_first = $MM_offset + 1;
$rs_last = $MM_offset + $MM_size;
if ($MM_rsCount != -1) {
$rs_first = $rs_first<$MM_rsCount?$rs_first:$MM_rsCount;
$rs_last = $rs_last<$MM_rsCount?$rs_last:$MM_rsCount;
}
// set the boolean used by hide region to check if we are on the last record
$MM_atTotal = ($MM_rsCount != -1 && $MM_offset + $MM_size >= $MM_rsCount);
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="estilo_noticias.css" type="text/css">
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th colspan="3" valign="top" scope="col">
<?include("superior.htm")?>
</th>
</tr>
<tr>
<td width="140" valign="top" bgcolor="#FFDF9D">
<?include("izquierda.htm")?>
</td>
<td width="480" valign="top" bgcolor="#FFFFFF">
<table width="460" border="0" align="center" cellspacing="0" cellpadding="0">
<tr>
<td class="texto_titulo" colspan="2">
<table border="0" cellpadding="0" cellspacing="0" width="436">
<!-- fwtable fwsrc="titulo.png" fwbase="titulo.jpg" fwstyle="Dreamweaver" fwdocid = "694147630" fwnested="0" -->
<tr>
<td><img src="img/spacer.gif" width="2" height="1" border="0" alt="" /></td>
<td><img src="img/spacer.gif" width="396" height="1" border="0" alt="" /></td>
<td><img src="img/spacer.gif" width="38" height="1" border="0" alt="" /></td>
<td><img src="img/spacer.gif" width="1" height="1" border="0" alt="" /></td>
</tr>
<tr>
<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>
<td><img src="img/spacer.gif" width="1" height="3" border="0" alt="" /></td>
</tr>
<tr>
<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>
<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">
<param name="movie" value="flash/ig_nuevos_productos.swf">
<param name="quality" value="high">
<param name="wmode" value="transparent">
<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">
</embed>
</object></td>
<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>
<td><img src="img/spacer.gif" width="1" height="25" border="0" alt="" /></td>
</tr>
<tr>
<td><img name="titulo_r3_c2" src="img/titulo_r3_c2.jpg" width="396" height="2" border="0" id="titulo_r3_c2" alt="" /></td>
<td><img src="img/spacer.gif" width="1" height="2" border="0" alt="" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="texto_titulo"> </td>
<td class="texto_titulo" valign="top"> </td>
</tr>
<tr>
<td colspan="2">
<?php while (($Repeat1__numRows-- != 0) && (!$rs->EOF))
{
?>
<table width="460" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="120"><img src="fotos_soporte/<?php echo $rs->Fields("id")?>.jpg" width="100" height="100"></td>
<td valign="top" width="340"><a href="pdf_soporte/<?php echo $rs-Fields("id")?>.pdf"><?php echo $rs->Fields("titulo")?></a><br />
<span class="texto_comentario">
<?php echo $rs->Fields("comentario")?>
</span></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2">
<hr>
</td>
</tr>
</table>
<?php
$Repeat1__index++;
$rs->MoveNext();
}
?>
</td>
</tr>
</table>
<p align="center"> </p>
<p align="right"><a href="javascript:window.history.back()"><span class="texto_comentario">>>
Regresar</span></a><br>
</p>
</td>
<td width="140" valign="top" bgcolor="#FFDF9D">
<?include("derecha.htm")?>
</td>
</tr>
<tr>
<td colspan="3" valign="top" bgcolor="#FFFFFF">
<?include("base.htm")?>
</td>
</tr>
</table>
</body>
</html>
<?php
$rs->Close();
?>
<?php
$rs->Close();
?>
<?php
$rs->Close();
?>
y el archivo para subir mis pdf es este:
subir_pdf.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=iso-8859-1" />
<title>::: Subir PDF ::</title>
<link rel="stylesheet" href="estilo_deportes.css" type="text/css">
<link rel="stylesheet" href="estilo_noticias.css" type="text/css">
</head>
<body bgcolor="#FFFFFF">
<p class="texto_titulo">Subir Archivos PDF::</p>
<ol>
<li><span class="texto_titulo">Nota:</span><br>
<span class="texto_comentario">para subir pdf tener en cuenta el numero
de IP noticia, ejemplo: si e IPnoticia es 1, el PDF debe llamarse 1.pdf</span></li>
</ol>
<p>
<?php
if ($enviar) {
move_uploaded_file($archivo,"pdf_soporte/$archivo_name");
$url = "pdf_soporte/".$archivo_name;
chmod($url,0777);
echo "PDF subido exitosamente";
}
else {
?>
</p>
<Form method="post" action="subir_pdf.php" enctype="multipart/form-data">
<input type="file" name="archivo">
<br>
<input name="enviar" type="submit">
<?php
}
?>
</body>
</html>