Ver Mensaje Individual
  #11 (permalink)  
Antiguo 16/02/2010, 13:06
patricia:)
 
Fecha de Ingreso: abril-2006
Ubicación: Venezuela
Mensajes: 126
Antigüedad: 18 años, 1 mes
Puntos: 0
Respuesta: guardar texto con espacio en un campo bd

este es el codigo de buscar:

Código:
<?
if (isset($cmdbuscar))
{
  if(empty($t1))
  {
   echo '<script>alert("Por favor llene todos los campos.");</script>';
  }
  else
  {
   
   $con=mysql_connect("localhost","root","123");
   mysql_select_db("controlestudio",$con);
      
   $sql=("SELECT * FROM materias WHERE cod_materia ='$t1'");
   $resultado=mysql_query($sql,$con);
   if(mysql_affected_rows()==0)
   {
    echo '<script>alert("La materia no existe.");</script>';
    
   } else {
   
     $row=mysql_fetch_array($resultado);
     $ci=$row['cod_materia'];
     $nombre=$row['descripcion'];
     $ucre=$row['ucredito'];
     $seme=$row['semestre'];
     mysql_free_result($resultado);
     mysql_close($con);
   
   }
 }
}

?>
ahora si me trae el contendo completo al momento de buscar (gracias a sus valioso aportes )

Pero aun no me elimina el registro acontinuacion detallo el codigo:

boton:
Código:
<input type="submit" name="cmdeli" id="cmdeli" value="Eliminar" onclick="avisarBorrado(<?= $ci ?>)" />
funcion validacion:
Código:
<script language="JavaScript">
function avisarBorrado(t1) {
 
 if (window.confirm("¿Estas realmente seguro de que deseas eliminar este registro?")) {
     
  
  location.href = "deletemateria.php?t1=" + t1;
  window.confirm("deletemateria.php?t1=" + t1);
  
 }
} 
</script>

documento de eliminacion:
<?php
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;
}
if ((isset($_GET['t1'])) && ($_GET['t1'] != ""))
{
$con=mysql_connect("localhost","root","123");
mysql_select_db("controlestudio",$con);
$sql=sprintf("delete FROM materias WHERE cod_materia =%s",
GetSQLValueString($_GET['t1'], "text"));
$resultado=mysql_query($sql,$con);
if(mysql_affected_rows()!=0)
{
echo "registro eliminado";

}
//mysql_free_result($resultado);
mysql_close($con);


}


?>