Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/01/2007, 13:59
mvlsistemas
 
Fecha de Ingreso: mayo-2004
Mensajes: 903
Antigüedad: 20 años
Puntos: 4
Re: A B M y mostrar registros en tablas

edit.php
Código PHP:
<?php include("cone.php"); ?>
<?php 
//recibimos las variables enviadas por el formulario 
$id_web=$_POST[id_web]; 
$web=$_POST[web]; 
$provincia=$_POST[provincia]; 
$ciudad=$_POST[ciudad]; 
$pais=$_POST[pais]; 
$hotel=$_POST[hotel]; 
$estrellas=$_POST[estrellas];
$vigencia=$_POST[vigencia];  
$sgl=$_POST[sgl]; 
$dbl=$_POST[dbl]; 
$tpl=$_POST[tpl];
$suite=$_POST[suite];
$cama=$_POST[cama];
$adicional=$_POST[adicional];
$htm=$_POST[htm];
//modificamos los datos de la base según variables recibidas 
$result mysql_query("update paquetes Set web='$web', provincia='$provincia', ciudad='$ciudad', pais='$pais', hotel='$hotel',estrellas='$estrellas',vigencia='$vigencia',sgl='$sgl',dbl='$dbl',tpl='$tpl',suite='$suite',cama='$cama',adicional='$adicional',htm='$htm' where id_web='$id'"$connect); 
if (!
$result) { 
$message 'Invalid query: ' mysql_error() . "\n"
$message .= 'Whole query: ' $query
die(
$message); 

header("location:at_esp_actualizar.php"); 
?>
actualizar.php
Código PHP:
<?php  
// Conexion, seleccion de base de datos
$enlace mysql_connect('localhost''user''pass')
   or die(
'No pudo conectarse : ' mysql_error());
mysql_select_db('name_bd') or die('No pudo seleccionarse la BD.');

//Sentencia sql (sin limit)
$_pagi_sql 'SELECT * FROM paquetes order by web Asc';

//cantidad de resultados por página (opcional, por defecto 20)
$_pagi_cuantos 20
//Incluimos el script de paginación. Éste ya ejecuta la consulta automáticamente
include("paginator.inc.php");
 
// Así escribimos la cabecera de la tabla
//Leemos y escribimos los registros de la página actual


echo '<table width="700" border="0" bgcolor="#B87C99"cellpadding="0" cellspacing="0" >';
echo 
'
  <tr> <td width="30"><font color="#FFFFFF"><strong>WEB</strong></font></td>
    <td width="140"><font color="#FFFFFF"><strong>Argentina</strong></font></td>
    <td width="20"><font color="#FFFFFF"> 
     <strong>*</strong></font></td>
    <td width="100" align="center"><font color="#FFFFFF"><strong>Vigencia</strong></font></td>
    <td width="30"><font color="#FFFFFF"><strong>SGL</strong></font></td>
    <td width="30"><font color="#FFFFFF"><strong>DBL</strong></font></td>
    <td width="30"><font color="#FFFFFF"><strong>TPL</strong></font></td>
    <td width="30"><font color="#FFFFFF"><strong>SUITE</strong></font></td>
    <td width="30" align="center"><img src="iconocama.gif" width="19" height="20"></td>
    <td width="40"><font color="#FFFFFF"><strong>ADICIONAL</strong></font></td>
     <td width="40" align="center"><font color="#FFFFFF"><strong>HTM</strong></font></td>
  <td ><font color="#FFFFFF"><strong>Editar</strong></font></td>
 <td ><font color="#FFFFFF"><strong>Borrar</strong></font></td>
  </tr>'
;
while(
$row mysql_fetch_array($_pagi_result)){ 
if (
$colorfila==0){
       
$color"#DEDEBE";
       
$colorfila=1;
    }else{
       
$color="#F0F0F0";
       
$colorfila=0;
    }
echo 
'<tr bgcolor='.$color.'>'.'<td>'.$row[web].'</td>'.'<td  height="20" width="150" height="4" >'.'<strong>'.$row['hotel'].'</td>'.'</strong>'.'<td height="20" width="10" align = "left" >'.'<strong>'.$row['estrellas'].'</td>'.'</strong>'.'<td width="100"  align = "center" >'.'<strong>'.$row['vigencia'].'</td>'.'</strong>'.'<td height="20" width="30" align = "center" >'.'<strong>'.$row['sgl'].'</td>'.'</strong>'.'<td height="20" width="30"  align = "center" >'.'<strong>'.$row['dbl'].'</td>'.'</strong>'.'<td height="20" width="30" align = "center" >'.'<strong>'.$row['tpl'].'</td>'.'</strong>'.'<td width="30"  align = "center" >'.'<strong>'.$row['suite'].'</td>'.'</strong>'.'<td height="20" width="30" align = "center">'.'<strong>'.$row['cama'].'</td>'.'</strong>'.'<td height="20" width="40" align="center">'.'<strong>'.$row['adicional'].'</td>'.'</strong>'.'<td height="20" width="40" align="center">'.'<strong>'.$row['htm'].'</td>'.'</strong>'.
'<td >'.'<font color="#003399">'.'<a href="editar.php?id='.$row[id_web].'">'.editar.'</a>'.'</font>'.'</td>'
.'<td >'.'<font color="#004466">'.'<a href="borrar.php?id='.$row[id_web].'">'.eliminar.'</a>'.'</font>'.'</td>'.'</tr>'



//Incluimos la barra de navegación
echo"<p>".$_pagi_navegacion."</p>";
?>
insertar.php
Código PHP:
<?
//Conexion con la base
mysql_connect("localhost","user","pass");
//Ejecucion de la sentencia SQL
mysql_db_query("name_bd","insert into paquetes (web,provincia,ciudad,pais,hotel,estrellas,vigencia,sgl,dbl,tpl,suite,cama,adicional,htm) values ('$web','$provincia','$ciudad','$pais','$hotel','$estrellas','$vigencia','$sgl','$dbl','$tpl','$suite','$cama','$adicional','$htm')");
?>

borrar.php
Código PHP:
<?php include("cone.php"); ?>
<?php 
//recibimos la variable $id 
$id=$_GET[id]; 
//borramos los registros pertenecientes a la id 
$result mysql_query("delete from paquetes where id_web='$id'",$connect); 
if (!
$result) { 
$message 'Invalid query: ' mysql_error() . "\n"
$message .= 'Whole query: ' $query
die(
$message); 

header("location: at_esp_actualizar.php"); 
?>
borra.php
Código PHP:
<?php include("cone.php"); ?>
<? 
//recibimos la variable $id 
$id=$_POST[id]; 
//borramos los registros pertenecientes a la id 
mysql_query("delete from paquetes where id_web='$id'",$connect); 
header("location: index.php");
?>
lo que necesito es saber como poder insertar y actualizar y borrar vs. registros a la vez sin tener que recurri a phpmyadmin, quizás con un check box tipo hotmail para borrar vs. mail juntos.

! mañana preparo un zip con todo y lo subo a mi web para que lo vean mejor, me parece que va ha ser mas práctico!

Última edición por mvlsistemas; 15/01/2007 a las 14:05