ciao,
ho questa funzione che mi permette di inserire un immagine in una categoria. Il problema è che ora dovrei modificarla al fine di poter inserire + di una immagine in ogni categoria.ho pensato che bastasse semplicemente escludere il ciclo condizionale if --> if ($result->EOF) { <-- in modo da abilitare (anche se ne ho gia 1 inserito nel db) un altro alrticolo
Codice PHP:
function ges_art_new50() {
include ("../config.inc");
include ("../adodbconnect.inc");
echo "<table width=\"50%\" border=\"1\" align=\"center\">\n"
."<tr>"
."<td width=\"25%\" align=\"center\">Gestione Articolo</td>"
."</tr>"
."</table>\n";
echo "</table>\n";
$sqltxt="select * from cat00";
$result = $db->Execute($sqltxt) or die("Errore nella QUERY: $sqltxt. " . $db->ErrorMsg());
echo "<table width=\"95%\" border=\"1\">\n";
echo "<tr>"
."<td width=\"30%\"><a href=\"admin.php?op=\">Amministrazione</a></td>"
."</tr>";
while (!$result->EOF) // inizio ciclo do while per MENU
{
$dbid0=$result->fields("id0");
$dbcat0=$result->fields("cat00");
echo "<tr>"
."<td width=\"30%\">$dbcat0</td>"
."<td width=\"5%\"><a href=\"admin.php?op=53&wid0=$dbid0\">[OK]</a></td>"
."</tr>";
$result->MoveNext();
}
echo "</table>\n";
}
//------------------------------------------------------------------------------
function ges_art_new53($wid0) {
include ("../config.inc");
include ("../adodbconnect.inc");
echo "<table width=\"50%\" border=\"1\" align=\"center\">\n"
."<tr>"
."<td width=\"25%\" align=\"center\">Gestione Articolo</td>"
."</tr>"
."</table>\n";
//echo "</table>\n";
echo "<table width=\"95%\" border=\"1\">\n";
include ("rag00.inc"); //-- gruppo 0 --
echo "</table>\n";
//------------------> articolo <------------------
$wid0 = intval($wid0); // anti inoculation con valori numerici
$sqltxt="select * from articolo where cat0=$wid0";
$result = $db->Execute($sqltxt) or die("Errore nella QUERY: $sqltxt. " . $db->ErrorMsg());
if ($result->EOF) {
echo "<table width=\"20%\" border=\"1\">\n"
."<tr>"
."<td width=\"20%\"><a href=\"admin.php?op=54&wid0=$dbid0\">Aggiungi Articolo</a></td>"
."</tr>"
."</table>\n";
}
else
{ // trovato
$dbid=$result->fields("id");
$dbtxt1=$result->fields("txt01");
$dbtxt2=$result->fields("txt02");
$fileimmagine="../$imagepathtoweb$imagepathtoweb_small/$dbid.jpg";
echo "<table width=\"20%\" border=\"1\">\n"
."<tr>"
."<td width=\"10%\"><a href=\"admin.php?op=56&wid=$dbid&wid0=$dbid0\">Modifica</a></td>"
."<td width=\"10%\"><a href=\"admin.php?op=58&wid=$dbid&wid0=$dbid0\" onclick=\"javascript:return confirmAction()\">Cancella</a></td>"
."</tr>"
."</table>\n";
echo "<table width=\"20%\" border=\"1\">\n"
."<tr>"
."<td width=\"20%\"><img src=\"$fileimmagine\" alt=\"\" title=\".1\" width=\"200\" height=\"150\" border=\"0\" /></td>"
."</tr>"
."</table>\n";
echo "<table width=\"90%\" border=\"1\">\n"
."<tr>"
."<td width=\"10%\">News 1</td>"
."<td width=\"80%\">$dbtxt1</td>"
."</tr>"
."<tr>"
."<td width=\"10%\">News 2</td>"
."<td width=\"80%\">$dbtxt2</td>"
."</tr>";
echo "</table>\n";
}
}
//==============================================================================
//============= INSERIMENTO ARTICOLO ===========================
function ges_art_new54($wid0) {
include ("../config.inc");
include ("../adodbconnect.inc");
echo "<table width=\"50%\" border=\"1\" align=\"center\">\n"
."<tr>"
."<td width=\"25%\" align=\"center\">Gestione Articolo</td>"
."</tr>"
."</table>\n";
echo "</table>\n";
echo "<table width=\"20%\" border=\"1\">\n";
include ("rag00.inc"); //-- gruppo 0 --
echo "</table>\n";
//------------------> FORM articolo <------------------
//echo "</table>\n";
echo"<form action=\"admin.php?op=55\" name=\"new_add_art\" method=\"post\" enctype=\"multipart/form-data\">\n"
."<table width=\"90%\" border=\"1\">\n"
."<tr>"
."<td width=\"20%\"></td>"
."<td width=\"70%\"><input type=\"submit\" name=\"store\" value=\"Memorizza\" /><input type=\"reset\" name=\"reimposta\" /></td>"
."</tr>"
//scelgo immagine
."<tr>"
."<td width=\"20%\">Associa Immagine:</td>"
."<td width=\"70%\"><input type=\"file\" size=\"100\" name=\"wfile\" /></td>"
."</tr>"
."<tr>"
."<td width=\"20%\">News 1</td>"
."<td width=\"70%\"><textarea name=\"wtxt01\" rows=\"4\" cols=\"90\"></textarea></td>"
."</tr>"
."<tr>"
."<td width=\"20%\">News 2</td>"
."<td width=\"70%\"><textarea name=\"wtxt02\" rows=\"4\" cols=\"90\"></textarea></td>"
."</tr>"
."</table>\n"
."<input type=\"hidden\" name=\"wid0\" value=\"$dbid0\" />"
."</form>\n";
}
//==============================================================================
//==============================================================================
function ges_art_new55($wid0,$wtxt01,$wtxt02,$wfile) {
include ("../config.inc");
include ("../adodbconnect.inc");
$wid0 = intval($wid0); // anti inoculation con valori numerici
//verifica
$sqltxt="INSERT INTO articolo (cat0,txt01,txt02) VALUES ($wid0,'$wtxt01','$wtxt02');";
$result = $db->Execute($sqltxt) or die("Errore nella QUERY: $sqltxt. " . $db->ErrorMsg());
$wid0 = intval($wid0); // anti inoculation con valori numerici
$sqltxt="select * from articolo where cat0=$wid0";
$result = $db->Execute($sqltxt) or die("Errore nella QUERY: $sqltxt. " . $db->ErrorMsg());
$dbid=$result->fields("id");
//-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-//
if ($wfile!="") {
$newname="$dbid.jpg";
$filegrosso="../".$imagepathtoweb.$imagepathtoweb_big."/".$newname; // directory immagini codificate
// echo"DEBUG-file-->$wfile
\n";
// echo"DEBUG-filegrosso-->$filegrosso
\n";
copy($wfile,$filegrosso);
//-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-//
//---------> creo immagine ridotta x icona <---//
//-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-//
$cur_dir="../".$imagepathtoweb.$imagepathtoweb_big;
$cur_file=$newname;
$w=200;
$h=150;
$filepiccolo="../".$imagepathtoweb.$imagepathtoweb_small; // ."/".$newname; // directory immagini codificate
// echo"DEBUG-curdir-->$cur_dir
\n";
// echo"DEBUG-curfile-->$cur_file
\n";
// echo"DEBUG-filepiccolo-->$filepiccolo
\n";
resize($cur_dir, $cur_file, $w,$h, $filepiccolo);
}
//-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-//
ges_art_new53($wid0);
}
//==============================================================================
function ges_art_new56($wid,$wid0) {
include ("../config.inc");
include ("../adodbconnect.inc");
echo "<table width=\"50%\" border=\"1\" align=\"center\">\n"
."<tr>"
."<td width=\"25%\" align=\"center\">Gestione Articolo</td>"
."</tr>"
."</table>\n";
echo "</table>\n";
echo "<table width=\"20%\" border=\"1\">\n";
include ("rag00.inc"); //-- gruppo 0 --
echo "</table>\n";
//------------------> FORM articolo <------------------
$wid = intval($wid); // anti inoculation con valori numerici
$sqltxt="select * from articolo where id=$wid "; //cat0=$wid0 and cat1=$wid1 and cat2=$wid2";
$result = $db->Execute($sqltxt) or die("Errore nella QUERY: $sqltxt. " . $db->ErrorMsg());
if ($result->EOF) {
}
else
{ // trovato
$dbid=$result->fields("id");
$dbtxt1=$result->fields("txt01");
$dbtxt2=$result->fields("txt02");
//------------------> FORM articolo <------------------
//<input type="button" value="Reload Page" onClick="window.location.reload()">
echo"<form action=\"admin.php?op=57\" name=\"new_add_art\" method=\"post\" enctype=\"multipart/form-data\">\n"
."<table width=\"90%\" border=\"1\">\n"
."<tr>"
."<td width=\"20%\"></td>"
// ."<td width=\"70%\"><input type=\"submit\" name=\"store\" value=\"Memorizza\" /><input type=\"reset\" name=\"reimposta\" /></td>"
."<td width=\"70%\"><input type=\"submit\" name=\"store\" value=\"Memorizza\" /><input type=\"reset\" name=\"reimposta\" /></td>"
."</tr>"
//scelgo immagine
."<tr>"
."<td width=\"20%\">Riassocia Immagine:</td>"
."<td width=\"70%\"><input type=\"file\" size=\"100\" name=\"wfile\" /></td>"
."</tr>"
."<tr>"
."<td width=\"20%\">News 1</td>"
."<td width=\"70%\"><textarea name=\"wtxt01\" rows=\"4\" cols=\"90\">$dbtxt1</textarea></td>"
."</tr>"
."<tr>"
."<td width=\"20%\">News 2</td>"
."<td width=\"70%\"><textarea name=\"wtxt02\" rows=\"4\" cols=\"90\">$dbtxt2</textarea></td>"
."</tr>"
."</table>\n"
."<input type=\"hidden\" name=\"wid\" value=\"$dbid\" />"
."<input type=\"hidden\" name=\"wid0\" value=\"$dbid0\" />"
."</form>\n";
//echo "-->$dbid<---";
}
}
Che ne dite?? potrebbe andare?? forse sbaglio il modo, ma se faccio in questo sistema mi da un errore: mi da la possibilità di modificare un file anche se non è presente nel db con successivo errore di query.
Grazie