Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/12/2011, 09:21
chumy_
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 14 años, 10 meses
Puntos: 0
editar-borrar en tabla

Hola, tengo una tabla, la cual me muestra los proyectos que tengo en una db,

Código PHP:
<?php require_once('Connections/localhost.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;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_proyectos = 15;
$pageNum_proyectos = 0;
if (isset(
$_GET['pageNum_proyectos'])) {
  
$pageNum_proyectos = $_GET['pageNum_proyectos'];
}
$startRow_proyectos = $pageNum_proyectos * $maxRows_proyectos;

mysql_select_db($database_localhost, $localhost);
$query_proyectos = "SELECT * FROM proyectos ORDER BY noper ASC";
$query_limit_proyectos = sprintf("%s LIMIT %d, %d", $query_proyectos, $startRow_proyectos, $maxRows_proyectos);
$proyectos = mysql_query($query_limit_proyectos, $localhost) or die(mysql_error());
$row_proyectos = mysql_fetch_assoc($proyectos);

if (isset(
$_GET['totalRows_proyectos'])) {
  
$totalRows_proyectos = $_GET['totalRows_proyectos'];
} else {
  
$all_proyectos = mysql_query($query_proyectos);
  
$totalRows_proyectos = mysql_num_rows($all_proyectos);
}
$totalPages_proyectos = ceil($totalRows_proyectos/$maxRows_proyectos)-1;

$queryString_proyectos = "";
if (!empty(
$_SERVER['QUERY_STRING'])) {
  
$params = explode("&", $_SERVER['QUERY_STRING']);
  
$newParams = array();
  foreach (
$params as $param) {
    if (
stristr($param, "pageNum_proyectos") == false && 
        
stristr($param, "totalRows_proyectos") == false) {
      
array_push($newParams, $param);
    }
  }
  if (
count($newParams) != 0) {
    
$queryString_proyectos = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_proyectos = sprintf("&totalRows_proyectos=%d%s", $totalRows_proyectos, $queryString_proyectos);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
<style type="text/css">
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 9px;
}
</style>
</head>

<body>
<table width="950" border="0" align="center" whidth="950">
  <tr align="center">
    <td><strong>NOMBRE DE PROYECTO</strong></td>
    <td><p><strong>N&deg; OPE.</strong></p></td>
    <td><strong>ADMINISTRADOR</strong></td>
    <td><strong>TIPO</strong></td>
    <td><strong>CORREO</strong></td>
    <td><strong>MODIFICACIÓN</strong></td>
    <td><strong>ELIMINAR</strong></td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_proyectos['proy']; ?></td>
      <td align="center"><?php echo $row_proyectos['noper']; ?></td>
      <td><?php echo $row_proyectos['admpro']; ?></td>
      <td><?php echo $row_proyectos['pert']; ?></td>
      <td><?php echo $row_proyectos['correo']; ?></td>
      <td align="center"><form id="editar" name="editar" method="post" action="editar_proyecto.php">
        <input type="submit" name="editar" id="editar" value="Modificar" />
      </form></td>
      <td align="center"><form id="borrar" name="borrar" method="post" action="">
        <input type="submit" name="borrar" id="borrar" value="Eliminar" />
      </form></td>
    </tr>
    <?php } while ($row_proyectos = mysql_fetch_assoc($proyectos)); ?>
</table>
<table width="950" border="0" align="center">
  <tr align="center">
    <td width="50"><?php if ($pageNum_proyectos > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_proyectos=%d%s", $currentPage, 0, $queryString_proyectos); ?>"><img src="imagenes/First.gif" /></a>
        <?php } // Show if not first page ?></td>
    <td width="50"><?php if ($pageNum_proyectos > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_proyectos=%d%s", $currentPage, max(0, $pageNum_proyectos - 1), $queryString_proyectos); ?>"><img src="imagenes/Previous.gif" /></a>
        <?php } // Show if not first page ?></td>
    <td>&nbsp;</td>
    <td width="50"><?php if ($pageNum_proyectos < $totalPages_proyectos) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_proyectos=%d%s", $currentPage, min($totalPages_proyectos, $pageNum_proyectos + 1), $queryString_proyectos); ?>"><img src="imagenes/Next.gif" /></a>
      <?php } // Show if not last page ?></td>
    <td width="50"><?php if ($pageNum_proyectos < $totalPages_proyectos) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_proyectos=%d%s", $currentPage, $totalPages_proyectos, $queryString_proyectos); ?>"><img src="imagenes/Last.gif" /></a>
      <?php } // Show if not last page ?></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result
($proyectos);
?>
y como ven, tambien hay dos botones, uno de editar y otro para borrar el proyecto.