Foros del Web » Programando para Internet » PHP »

Echo en un registro php

Estas en el tema de Echo en un registro php en el foro de PHP en Foros del Web. Hola: Tengo este codigo. Como hago para que php me muestre un mensaje de "Esta fecha ya esta asignada" y "esta hora ya está asignada" ...
  #1 (permalink)  
Antiguo 22/05/2011, 10:42
Usuario no validado
 
Fecha de Ingreso: diciembre-2009
Ubicación: Bogotá
Mensajes: 462
Antigüedad: 14 años, 4 meses
Puntos: 18
Echo en un registro php

Hola: Tengo este codigo. Como hago para que php me muestre un mensaje de "Esta fecha ya esta asignada" y "esta hora ya está asignada"

se que se hace con if y echo pero no logro ponerlo donde es....



<?php require_once('Connections/citas.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;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO citas (idcc, idtipo, fecha, hora) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['idcc'], "text"),
GetSQLValueString($_POST['idtipo'], "text"),
GetSQLValueString($_POST['fecha'], "text"),
GetSQLValueString($_POST['hora'], "text"));

mysql_select_db($database_citasjoya, $citasjoya);
$Result1 = mysql_query($insertSQL, $citasjoya) or die(mysql_error());

$insertGoTo = "enproceso.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_citasjoya, $citasjoya);
$query_rc_citas = "SELECT * FROM citas";
$rc_citas = mysql_query($query_rc_citas, $citasjoya) or die(mysql_error());
$row_rc_citas = mysql_fetch_assoc($rc_citas);
$totalRows_rc_citas = mysql_num_rows($rc_citas);

mysql_select_db($database_citasjoya, $citasjoya);
$query_rc_depto = "SELECT * FROM depto";
$rc_depto = mysql_query($query_rc_depto, $citasjoya) or die(mysql_error());
$row_rc_depto = mysql_fetch_assoc($rc_depto);
$totalRows_rc_depto = mysql_num_rows($rc_depto);

mysql_select_db($database_citasjoya, $citasjoya);
$query_rc_reg = "SELECT * FROM registrados";
$rc_reg = mysql_query($query_rc_reg, $citasjoya) or die(mysql_error());
$row_rc_reg = mysql_fetch_assoc($rc_reg);
$totalRows_rc_reg = mysql_num_rows($rc_reg);

mysql_select_db($database_citasjoya, $citasjoya);
$query_rc_tipo = "SELECT * FROM tipotramite";
$rc_tipo = mysql_query($query_rc_tipo, $citasjoya) or die(mysql_error());
$row_rc_tipo = mysql_fetch_assoc($rc_tipo);
$totalRows_rc_tipo = mysql_num_rows($rc_tipo);

mysql_select_db($database_citasjoya, $citasjoya);
$query_rc_hora = "SELECT * FROM hora";
$rc_hora = mysql_query($query_rc_hora, $citasjoya) or die(mysql_error());
$row_rc_hora = mysql_fetch_assoc($rc_hora);
$totalRows_rc_hora = mysql_num_rows($rc_hora);
?>
<!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=utf-8" />
<title>Documento sin título</title>
<link type="text/css" rel="stylesheet" href="css/jscal2.css" />
<link type="text/css" rel="stylesheet" href="css/border-radius.css" />
<link id="skin-steel" title="Steel" type="text/css" rel="alternate stylesheet" href="css/steel/steel.css" />
<script src="js/jscal2.js"></script>
<script src="js/unicode-letter.js"></script>
<script src="js/lang/es.js"></script>
<link type="text/css" rel="stylesheet" href="css/demopage.css" />
<link type="text/css" rel="stylesheet" href="css/micss.css" />
</head>

<body>
<div align="center">
<table width="1024" border="0">
<tr>
<td><div align="center"></div></td>
</tr>
<tr>
<td><div align="center">
<form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Tipo de cita:</td>
<td><select name="idtipo">
<?php
do {
?>
<option value="<?php echo $row_rc_tipo['idtramit']?>" ><?php echo $row_rc_tipo['tramites']?></option>
<?php
} while ($row_rc_tipo = mysql_fetch_assoc($rc_tipo));
?>
</select></td>
</tr>
<tr> </tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fecha:</td>
<td><input name="fecha" id="calendar-inputField" /><button id="calendar-trigger">...</button>
<script>//<![CDATA[
Calendar.setup({ trigger: "calendar-trigger", inputField: "calendar-inputField" });
//]]></script> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Hora:</td>
<td><select name="hora">
<?php
do {
?>
<option value="<?php echo $row_rc_hora['idhorario']?>" ><?php echo $row_rc_hora['horario']?></option>
<?php
} while ($row_rc_hora = mysql_fetch_assoc($rc_hora));
?>

</select></td>
</tr>
<tr> </tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Insertar registro" /></td>
</tr>
</table>
<input type="hidden" name="idcc" value="" />
<input type="hidden" name="MM_insert" value="form2" />
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div></td>
</tr>
<tr>
<td><div align="center"></div></td>
</tr>
<tr>
<td><div align="center"></div></td>
</tr>
</table>
</div>
</body>
</html>
<?php
mysql_free_result($rc_citas);

mysql_free_result($rc_depto);

mysql_free_result($rc_reg);

mysql_free_result($rc_tipo);

mysql_free_result($rc_hora);
?>

Agradezco su ayuda
Estoy usando esto, pero no se si esta bie o a dónde va...
<?php
if (mysql_num_rows($row_rc_citas) == 1){
echo "Ya Existe";
}
?>

Última edición por isabellawebs; 22/05/2011 a las 11:21

Etiquetas: echo, registro
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:27.