<?php require_once('../Connections/conexionbd.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
mysql_select_db($database_conexionbd, $conexionbd);
$query_DatosProvincias = "SELECT * FROM tblprovincias ORDER BY strprovincia ASC";
$DatosProvincias = mysql_query($query_DatosProvincias, $conexionbd) or die(mysql_error());
$row_DatosProvincias = mysql_fetch_assoc($DatosProvincias);
$totalRows_DatosProvincias = mysql_num_rows($DatosProvincias);
function se_puede_eliminar($condicion) {
global $conexionbd;
$sql="Select * from tbl WHERE intprovincia=$condicion";
$DatosConsulta = mysql_query($sql, $conexionbd) or die(mysql_error());
$totalRows_DatosConsulta = mysql_num_rows($DatosConsulta);
if ($totalRows_DatosConsulta==0) {
return 'true';
}
else
{
return 'false';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/plantillaadmin.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Administracion provincias</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="../css/estiloadmin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<div class="header"><?php include("../includes/cabecera_admin.php"); ?></div>
<div class="sidebar1">
<?php include("../includes/menuizquierda_admin.php"); ?>
<p> </p>
<!-- end .sidebar1 --></div>
<div class="content"><!-- InstanceBeginEditable name="ContenidoDerechaAdmin" -->
<script>
function asegurar($valor)
{
rc="<?php
se_puede_eliminar(16)
?>";
if (rc=='true') {
rc = confirm("Seguro que desea eliminar?");
return rc;
}
else {
alert("Existen registros con este valor en otras tablas");
return false;
}
}
</script>
<form action="hola" method="post" name="form1" id="form1">
<h1>Lista de Provincias</h1>
<p><a href="provincias_add.php"><img src="images/icono_add.png" width="16" height="16" />Añadir Registro</a></p>
<p></p>
<table width="60%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr class="tablacabecera">
<td width="500px">Provincia</td>
<td>Accion</td>
</tr>
<?php do { ?>
<tr>
<td style="background:#F7F7F7"; width="90px" >
<div style="width:100%; overflow:auto; font-size:10px">
<?php echo $row_DatosProvincias['strprovincia']; ?>
</div>
</td>
<td>
<div id="accion" <?php if(mysql_num_rows($DatosProvincias) == 0){ echo ' style="display: none; width:100%; overflow:auto; font-size:10px"'; } ?>>
<a href="provincias_edit.php?recordID=<?php echo $row_DatosProvincias['intprovincia']; ?>"><img src="images/icono_edit.png" width="16" height="16" /></a> <a href="provincias_remove.php?recordID=<?php echo $row_DatosProvincias['intprovincia']; ?>"><img src="images/icono_remove.png" width="16" height="16" onClick="javascript:return asegurar(<?php echo $row_DatosProvincias['intprovincia']; ?>);"/>
</a>
</div>
</td>
</tr>
<?php } while ($row_DatosProvincias = mysql_fetch_assoc($DatosProvincias)); ?>
</table>
<!-- InstanceEndEditable -->
</div>
<div class="footer">
<?php include("../includes/pie_admin.php"); ?></div>
<!-- end .container --></div>
</body>
<!-- InstanceEnd --></html>
</form>
<?php
mysql_free_result($DatosProvincias);
?>