← Back
Editing: gallerie_ed.php
<?php #______________________________________________________________________# ### made with SmaDIB: Smart Database Interface Builder 0.4.0 ### ### by Smartmedia 2000 http://www.smartmedia2000.it/ ### ### info email: smadib@smartmedia2000.it ### ### released under GPL license http://www.gnu.org/licenses/gpl.txt ### ###___###___###___###___###____###____###____###___###___###___###___### require_once ("../funct.php"); require_once ("sess.php"); require_once ("conn.php"); $ptitolo = "Gestione Gallerie"; $table = "gallerie"; require_once ("testacoda.php"); $query = new doQuery(); $novuoto = array('nome_it'); $ordine = $_REQUEST['ordine']; $ordineOld = $_REQUEST['ordineOld']; if ($op == "ord") { $rows = $query->freeQuery ("SELECT `id`, `ordine` FROM `$table` WHERE `id_utente`='$id_utente' ORDER BY `ordine` ASC, `id` ASC", 0, $conn); foreach ($rows as $i=>$row0) $query->freeQuery ("UPDATE `$table` SET `ordine`='".($i+1)."' WHERE `id`=".$row0->id, 0, $conn); } $gallerie_id = array (0); $gallerie_ordine = array (1000); $rows = $query->freeQuery ("SELECT `id`, `ordine` FROM `gallerie` WHERE `id_utente` = $id_utente ORDER BY `ordine`, `id` ASC", 0, $conn); foreach ($rows AS $i=>$row0) { $gallerie_id[] = $row0->id; $gallerie_ordine[] = $row0->ordine; $maxOrd = $row0->ordine; } $posOrd = array_search ($ordine, $gallerie_ordine); if ($posOrd == "") $posOrd = count($gallerie_ordine); if ($ordine == "") $ordine = $maxOrd+1; if ($az == "canc") { $ord = $query->selectFldAs ($table, array ('ordine'=>'ordine'), 1); for ($i=$ord[0]; $i<=count($gallerie_id); $i++) $query->freeQuery ("UPDATE `$table` SET `ordine` = ".$i." WHERE `id_utente` = $id_utente AND `ordine` = ".($i+1), 0); $query->delete (); header("Location: ".$_SERVER['PHP_SELF']); } if ($op == "ds") { $query->insert ($_POST, $novuoto); for ($i=$posOrd; $i<count($gallerie_ordine); $i++) $query->freeQuery ("UPDATE `$table` SET `ordine` = ".($gallerie_ordine[$i]+1)." WHERE `id` = $gallerie_id[$i]", 0); header("Location: ".$_SERVER['PHP_SELF']); } else if ($op == "up") { $query->update ($_POST, $novuoto); if ($ordine >= $ordineOld) { $nn = -1; $posOrd = array_search ($ordineOld+1, $gallerie_ordine); $limO = $ordine+1; } else { $nn = 1; $limO = $ordineOld; } if ($ordine != $ordineOld) for ($i=$posOrd; $i<$limO; $i++) if ($gallerie_id[$i] != $id) $query->freeQuery ("UPDATE `$table` SET `ordine` = ".($gallerie_ordine[$i]+$nn)." WHERE `id` = $gallerie_id[$i]", 0); header("Location: ".$_SERVER['PHP_SELF']); } else if ($op == "upme") { $table = "meta"; $query->update ($_POST, array ()); $table = "gallerie"; } if ($az == "ed") { $row = $query->selectById (1); $id = $row['id']; $ordine = $row['ordine']; $valop = "up"; } else $valop = "ds"; $rowM = $query->freeQuery ("SELECT * FROM `meta` WHERE `id_utente` = ".$id_utente, 1); for ($i=0; $i<count ($lingue); $i++) { $k = array_search ($lingue[$i], $sigLng); if ($lingue[$i] == "it") { $uno = "<b>Ordine</b>"; $due = "<select name=\"ordine\"><option value=\"".$ordine."\">$ordine</option>\n"; for ($s=1; $s<=$maxOrd; $s++) $due.= "<option value=\"$s\">$s</option>\n"; $due.= "<option value=\"\"> </option></select>\n"; } else {$uno = ""; $due = "";} $elenco.= "<tr><td colspan=\"2\" align=\"right\">$uno </td><td><b>".$nomiLng[$lingue[$i]]."</b></tr> <tr><td colspan=\"2\" align=\"right\">$due </td><td><input name=\"nome_".$lingue[$i]."\" type=\"text\" size=\"60\" maxlenght=\"\" value=\"".$row[$k+2]."\" /></td></tr>\n"; $elencoMeta.= "<table align=\"center\" width=\"400\"> <tr bgcolor=\"#FFFFFF\"> <td>Titolo ".$nomiLng[$lingue[$i]]." (max 60 caratteri)<br /> <input type=\"text\" name=\"titlphoto_".$lingue[$i]."\" value=\"".$rowM[0]['titlphoto_'.$lingue[$i]]."\" size=\"80\" maxlength=\"60\" /></td> </tr><tr bgcolor=\"#FFFFFF\"> <td>Descrizione ".$nomiLng[$lingue[$i]]." (max 160 caratteri)<br /> <textarea name=\"descphoto_".$lingue[$i]."\" id=\"desc\" rows=\"2\" cols=\"80\">".$rowM[0]['descphoto_'.$lingue[$i]]."</textarea></td> </tr><tr bgcolor=\"#FFFFFF\"> <td>Parole chiave o frasi separate dalla virgola ".$nomiLng[$lingue[$i]]." (max 150 caratteri)<br /> <textarea name=\"keywphoto_".$lingue[$i]."\" id=\"keyw\" rows=\"2\" cols=\"80\">".$rowM[0]['keywphoto_'.$lingue[$i]]."</textarea></td> </tr></table><br />\n"; } $elenco.= "<tr><td colspan=\"3\"> <div align=\"center\"><input type=\"submit\" value=\"$intesta\" />$noMod</div> <input type=\"hidden\" name=\"op\" value=\"$valop\" /> <input type=\"hidden\" name=\"ordineOld\" value=\"$ordine\" /> <input type=\"hidden\" name=\"id\" value=\"$id\" /> </td></tr>\n"; $cc = 0; $rows = $query->selectAll($table, array('ordine'=>'ASC'), 0); foreach ($rows as $i=>$row) { $cc++; $colriga = colriga ($cc); $elenco.= "<tr bgcolor=\"#$colriga\"><td>\n"; if ($az != "ed") $elenco.= "<a href=\"".$_SERVER['PHP_SELF']."?id=".$row->id."&az=ed\" title=\"modifica riga\"><img src=\"images/edit.gif\" border=\"0\" alt=\"modifica\"></a> <a href=\"#\" onClick=\"javascript:confDel(".$row->id.")\" title=\"cancella riga\"><img src=\"images/delete.gif\" border=\"0\" alt=\"cancella\"></a>\n"; $elenco.= " </td><td align=\"center\">".$row->ordine." </td><td>".$row->nome_it."</td>\n"; } echo $testa; ?> <h2><div align="center"><?php echo $ptitolo; ?></div></h2> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table align="center"> <?php echo $elenco; ?> </table></form> <!--input type="button" value="Ricostruisci ordine" onclick="javascript:document.location='<?php echo $_SERVER['PHP_SELF']; ?>?op=ord'" /--> <?php if ($az != "ed") { ?> <hr> <h2><div align="center">SEO - ottimizzazione motori di ricerca</div></h2> <form name="form2" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <?php echo $elencoMeta; ?> <div align="center"> <input type="submit" name="invio" value="Salva meta" /> <input type="hidden" name="id" value="<?php echo $rowM[0]['id']; ?>" /> <input type="hidden" name="op" value="upme" /> </div></form> <?php } echo $coda; ?>
Save File
Cancel