codigo de lista de categoria
Código PHP:
Ver original<?php require_once('../Connections/evatienda.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
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;
}
}
$query_category = "SELECT * FROM categoria ORDER BY categoria.`description` ASC";
?>
<div class="content">
<h2>Lista de categorías </h2>
<table width="100%" border="0" align="center" cellpadding="6" cellspacing="6">
<tr>
<td width="48%" bgcolor="#FFFFFF">Nombre de la categoria</td>
<td width="52%" bgcolor="#FFFFFF">Acciones</td>
</tr>
<tr>
<?php do { ?>
<td><?php echo $row_category['description']; ?></td>
<td>Editar - Eliminar</td>
</tr>
</table>
Codigo de añadir categoria
Código PHP:
Ver original<?php require_once('../Connections/evatienda.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
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 categoria (`description`) VALUES (%s)", GetSQLValueString($_POST['description'], "text"));
$insertGoTo = "categorias_listas.php";
if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ?
"&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING'];
}
}
?>
<div class="content">
<h2>Añadir categoras</h2>
<p> </p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Descripción:</td>
<td><input type="text" name="description" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insertar categoria" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>