PHP - Abrir pdf

 
Vista:

Abrir pdf

Publicado por dirab51 (2 intervenciones) el 27/03/2009 10:45:55
Hola amigos ya solucione el problema de otro script anterior de un sistema de noticias que no me dejama subir pdfs, sino imagenes.
El problema ahora es que a la hora de abrir una noticia con imagenes vá perfecto, pero a la hora de abrir una con pdf me sale el tipico cuadrito de que no hay imagen y no se abre el pdf.
¿Se podría hacer que cuando sea un pdf, mostrara una imagen que tengo en la carpeta llamada pdf.jpg, y que al pinchar encima se abriera el pdf.

La url es esta por si lo quereis ver:
http://dirab51.net/news/

El script es este:

<?php
require("./NewsSql.inc.php");
$db = new NewsSQL($DBName);
if ((!empty($PR)) && ($Rating>=1)){
$db->set_Rating($newsid,$Rating);
}
$result = $db->getnewsbyid($newsid);
$title = $result[0]["title"];
$content = $result[0]["content"];
$picture = $result[0]["picture"];
$picturepath = "./photo/";
$viewnum = $result[0]["viewnum"];
$sourceurl = $result[0]["sourceurl"];
$source = $result[0]["source"];
$adddate = $result[0]["adddate"];
$db->addhit($viewnum,$newsid);
$Rate = $result[0]["rating"];
$Rate1 = $Rate*10;
$Rate2 = ceil($Rate1);
$Rate = $Rate2/10;

$pre[0] = $newsid-1;

for ($i=1; $i<=$prenumber-1; $i++){
$pre[$i] = $pre[$i-1]-1;
}

$next[0] = $newsid+1;

for ($i=1; $i<=$nextnumber-1; $i++){
$next[$i] = $next[$i-1]+1;
}

?>
<html>
<head>
<title><?php print "$title"; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php print "$front_charset"; ?>">
<link rel="stylesheet" href="./style/style.css" type="text/css">
<script language="JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<?php
include("top.php3");
?>
<table width="412" border="0" cellspacing="1" cellpadding="0" align="center" class="table_01">
<tr>
<td class="menu" bgcolor="#FFFFFF" valign="top" width="410">
<div align="left">
<table width="410" border="0" cellspacing="0" cellpadding="4">
<tr>
<td bgcolor="#F2F2F2" class="menu_in">::<? print "$title"; ?></td>
</tr>
<?php
if (!empty($picture)){

print "<tr>
<td align="center"><img src="$picturepath$picture" alt="$title"></td>
</tr>";

}

if (!empty($content)){
$content = nl2br($content);
print "<tr>
<td>$content</td>
</tr>";
}

if (!empty($sourceurl)){
print "<tr>
<td bgcolor="#F2F2F2" class="menu_in">$front_source :</td>
</tr>
<tr>
<td><a href="$sourceurl" class="en_b" target="_blank">$source</a></td>
</tr>";
}
else {
if (!empty($source)){
print "<tr>
<td bgcolor="#F2F2F2" class="menu_in">$front_source :</td>
</tr>
<tr>
<td>$source</td>
</tr>";
}
}

if (!empty($adddate)){
print "<tr>
<td bgcolor="#F2F2F2" class="menu_in">$front_adddate :</td>
</tr>
<tr>
<td>$adddate</td>
</tr>";
}

for ($i=0; $i<=$prenumber-1; $i++){
$prename[$i] = $db->getname($pre[$i]);
if (!empty($prename[$i])){
$prenotemptytag = true;
}
}
for ($i=0; $i<=$nextnumber-1; $i++){
$nextname[$i] = $db->getname($next[$i]);
if (!empty($nextname[$i])){
$nextnotemptytag = true;
}
}
if (($prenotemptytag)||($nextnotemptytag)){
print "<tr>
<td bgcolor="#F2F2F2" class="menu_in">$front_more ...</td>
</tr>
<tr>
<td>";
for ($i=0; $i<=$prenumber-1; $i++){
if (!empty($prename[$i])){
print "<a href="news.php?newsid=$pre[$i]" class="en_b">$prename[$i]</a><br>";
}
}

for ($i=0; $i<=$nextnumber-1; $i++){
if (!empty($nextname[$i])){
print "<a href="news.php?newsid=$next[$i]" class="en_b">$nextname[$i]</a><br>";
}
}
print "</td>
</tr>";
}

?>
</table>
</div></td>
</tr>
</table>
</body>
</html>

Gracias por todo
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder