ciao a tutti
visualizzando con il seguente script 6 immagini per riga mi ignora sempre e solo la 7a immagine e non riesco a capire il perchè?
Codice PHP:
<?php
// CONNESSIONE AL MYSQL
@mysql_connect("localhost", "nori", "nori") or die("Connessione fallita !");
// SELEZIONE DATABASE
@mysql_select_db("planetmodels") or die("Selezione Database fallita !");
// TIPI DI FILE VISUALIZZABILI
$visualizzabili = array("image/jpeg", "image/pjpeg", "image/gif", "image/png");
$query = "SELECT * FROM foto";
$select = @mysql_query($query) or die("Query fallita !");
echo "<div align=\"center\">";
echo "<table border=\"1\" width=\"732\">";
$cont_td = 0;
echo " <tr>\n";
while($result = @mysql_fetch_array($select)) {
if($cont_td < 6) {
if(in_array($result["foto_tipo"], $visualizzabili)) {
echo "<td align=\"center\">";
echo "<img src=\"action.php?action=view&Id=" . $result["foto_id"] . "\">";
echo "
\n";
echo $result["foto_modelnome"];
echo "</td>\n";
$cont_td = $cont_td+1;
}
}
else {
$cont_td = 0;
echo "</tr>\n";
echo "<tr>\n";
}
}
echo "</table>\n</div>\n";
// CHIUDIAMO LA CONNESSIONE A MYSQL
@mysql_close();
?>
tenendo in considerazione che la pagina action.php è la seguente:
Codice PHP:
<?php
if(!isset($_GET)) $_GET = $HTTP_GET_VARS;
if($_GET["action"] && $_GET["Id"] && is_numeric($_GET["Id"])) {
// CONNESSIONE AL MYSQL
@mysql_connect("localhost", "nori", "nori") or die("Connessione fallita !");
// SELEZIONE DATABASE
@mysql_select_db("planetmodels") or die("Selezione Database fallita !");
switch($_GET["action"]) {
// VISUALIZZAZIONE
case "view" :
$query = "SELECT foto_1small, foto_tipo FROM foto WHERE foto_id = '" . $_GET["Id"] . "'";
$select = @mysql_query($query) or die("Query fallita !");
$result = @mysql_fetch_array($select);
$data = $result["foto_1small"];
$type = $result["foto_tipo"];
Header("Content-type: $type");
echo $data;
break;
// DOWNLOAD
case "download" :
$query = "SELECT foto_1small, foto_1smallname, foto_tipo FROM foto WHERE foto_id = '" . $_GET["Id"] . "'";
$select = @mysql_query($query) or die("Query fallita !");
$result = @mysql_fetch_array($select);
$data = $result["foto_1small"];
$name = $result["foto_1smallname"];
$type = $result["foto_tipo"];
// SE IL BROWSER E' INTERNET EXPLORER
if(ereg("MSIE ([0-9].[0-9]{1,2})", $_SERVER["HTTP_USER_AGENT"])) {
header("Content-Type: application/octetstream");
header("Content-Disposition: inline; filename=$name");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public");
} else {
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$name");
header("Expires: 0");
header("Pragma: no-cache");
}
echo $data;
break;
default :
// DEFAULT CASE, NESSUNA AZIONE
break;
} // endswitch
// CHIUDIAMO LA CONNESSIONE
@mysql_close();
} //endif
?>