Me pide unas opciones, las relleno según dice la ayuda, y luego miro el resultado, pero veo que no ha alterado nada en el formulario, y al subirlo a iespana y probar pues veo que no hace nada de nada. ¿Me podéis echar una mano?
El código que genera DW:
Código PHP:
<?php
$currentPage = $_SERVER["PHP_SELF"];
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO CMS (marca, price, `desc`, ID, title) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['textfield3'], "text"),
GetSQLValueString($_POST['textfield5'], "text"),
GetSQLValueString($_POST['textfield4'], "text"),
GetSQLValueString($_POST['textfield2'], "double"),
GetSQLValueString($_POST['textfield'], "text"));
mysql_select_db($database_database, $database);
$Result1 = mysql_query($insertSQL, $database) or die(mysql_error());
$insertGoTo = "../index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST['ID'])) && ($_POST['ID'] != "")) {
$deleteSQL = sprintf("DELETE FROM CMS WHERE ID=%s",
GetSQLValueString($_POST['ID'], "int"));
mysql_select_db($database_database, $database);
$Result1 = mysql_query($deleteSQL, $database) or die(mysql_error());
$deleteGoTo = "eliminar.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
if ((isset($_POST['select'])) && ($_POST['select'] != "") && (isset($_POST['eliminar']))) {
$deleteSQL = sprintf("DELETE FROM CMS WHERE title=%s",
GetSQLValueString($_POST['select'], "text"));
mysql_select_db($database_database, $database);
$Result1 = mysql_query($deleteSQL, $database) or die(mysql_error());
$deleteGoTo = "eliminar.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "insertar")) {
$insertSQL = sprintf("INSERT INTO CMS (marca, price, `desc`, ID, title) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['textfield7'], "text"),
GetSQLValueString($_POST['textfield9'], "text"),
GetSQLValueString($_POST['textfield8'], "text"),
GetSQLValueString($_POST['textfield10'], "double"),
GetSQLValueString($_POST['textfield6'], "text"));
mysql_select_db($database_database, $database);
$Result1 = mysql_query($insertSQL, $database) or die(mysql_error());
}
$maxRows_sitio = 1;
$pageNum_sitio = 0;
if (isset($_GET['pageNum_sitio'])) {
$pageNum_sitio = $_GET['pageNum_sitio'];
}
$startRow_sitio = $pageNum_sitio * $maxRows_sitio;
mysql_select_db($database_database, $database);
$query_sitio = "SELECT sitename, sitedesc FROM CMS";
$query_limit_sitio = sprintf("%s LIMIT %d, %d", $query_sitio, $startRow_sitio, $maxRows_sitio);
$sitio = mysql_query($query_limit_sitio, $database) or die(mysql_error());
$row_sitio = mysql_fetch_assoc($sitio);
if (isset($_GET['totalRows_sitio'])) {
$totalRows_sitio = $_GET['totalRows_sitio'];
} else {
$all_sitio = mysql_query($query_sitio);
$totalRows_sitio = mysql_num_rows($all_sitio);
}
$totalPages_sitio = ceil($totalRows_sitio/$maxRows_sitio)-1;
$maxRows_articulo = 1;
$pageNum_articulo = 0;
if (isset($_GET['pageNum_articulo'])) {
$pageNum_articulo = $_GET['pageNum_articulo'];
}
$startRow_articulo = $pageNum_articulo * $maxRows_articulo;
mysql_select_db($database_database, $database);
$query_articulo = "SELECT marca, price, `desc`, ID, title, image FROM CMS ORDER BY ID ASC";
$query_limit_articulo = sprintf("%s LIMIT %d, %d", $query_articulo, $startRow_articulo, $maxRows_articulo);
$articulo = mysql_query($query_limit_articulo, $database) or die(mysql_error());
$row_articulo = mysql_fetch_assoc($articulo);
if (isset($_GET['totalRows_articulo'])) {
$totalRows_articulo = $_GET['totalRows_articulo'];
} else {
$all_articulo = mysql_query($query_articulo);
$totalRows_articulo = mysql_num_rows($all_articulo);
}
$totalPages_articulo = ceil($totalRows_articulo/$maxRows_articulo)-1;
$queryString_articulo = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_articulo") == false &&
stristr($param, "totalRows_articulo") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_articulo = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_articulo = sprintf("&totalRows_articulo=%d%s", $totalRows_articulo, $queryString_articulo);
$queryString_sitio = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_sitio") == false &&
stristr($param, "totalRows_sitio") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_sitio = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_sitio = sprintf("&totalRows_sitio=%d%s", $totalRows_sitio, $queryString_sitio);
?>
Código PHP:
<form id="eliminar" name="eliminar" method="POST" action="">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="52%"><strong>Artículo a eliminiar: </strong></td>
<td width="48%"><label>
<select name="select">
<?php
do {
?>
<option value="<?php echo $row_articulo['title']?>"><?php echo $row_articulo['title']?></option>
<?php
} while ($row_articulo = mysql_fetch_assoc($articulo));
$rows = mysql_num_rows($articulo);
if($rows > 0) {
mysql_data_seek($articulo, 0);
$row_articulo = mysql_fetch_assoc($articulo);
}
?>
</select>
<span class="Estilo1"><a href="<?php printf("%s?pageNum_articulo=%d%s", $currentPage, min($totalPages_articulo, $pageNum_articulo + 1), $queryString_articulo); ?>">Siguiente</a> | <a href="<?php printf("%s?pageNum_sitio=%d%s", $currentPage, max(0, $pageNum_sitio - 1), $queryString_sitio); ?>">Anterior</a></span></label></td>
</tr>
</table>
<input type="submit" value="Eliminar"/>
Atención:Una vez eliminado no hay vuelta atrás
</form>
Saludos