Ver Mensaje Individual
  #3 (permalink)  
Antiguo 14/07/2008, 19:21
Ghosty
 
Fecha de Ingreso: junio-2008
Mensajes: 292
Antigüedad: 15 años, 11 meses
Puntos: 4
Respuesta: nombre de tabla

Me esplico....kiero hacer una sistema de base de datos para una consulta medica; y necestito hacer estas tablas en la BD

-una con todos los nombre delos pacientes (datos personales)

-y una tabla para cada usuario con su historial medico puesto que este va a tener varios registros y tengo que mostrarlos todos.

mi intencion es poner como nombre de la tabla del historial la id de cada paciente asi la el paciente 1 ira con el historial 1 el 2 con la 2 etc

y para ello e exo esto despues del alta (datos personales)


Código PHP:
<?php require_once('Connections/doctrobd.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$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_doctrobd$doctrobd);
$query_Recordset1 "SELECT * FROM pacientes ORDER BY id DESC";
$Recordset1 mysql_query($query_Recordset1$doctrobd) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?><!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&iacute;tulo</title>
</head>

<body>
<p><?php echo $row_Recordset1['id']; ?></p>
<p><?php echo $row_Recordset1['nombre']; ?></p>
<p><?php echo $row_Recordset1['apellidos']; ?></p>
<p><?php echo $row_Recordset1['nacimiento']; ?></p>
<p><?php echo $row_Recordset1['dni']; ?></p>
<p><?php echo $row_Recordset1['direccion']; ?></p>
<p><?php echo $row_Recordset1['mail']; ?></p>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="altahistoria.php">
  <label>
  <input name="nombre_tabla" type="text" id="nombre_tabla" value="<?php echo $row_Recordset1['id']; ?>" />
  </label>
  <label>
  <input type="submit" name="button" id="button" value="Enviar" />
  </label>
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
   
//conexion al servidor
   
mysql_connect("localhost","root","");
   
//seleccionar la base de datos
   
mysql_select_db("doctor");
   
//setencia sql para crear la tabla
   
$nombre_tabla 
   
$sql="CREATE TABLE $nombre_tabla (
`firma_ID` int(11) NOT NULL auto_increment, 
`usuario` varchar(25) NOT NULL, 
`titulo` varchar(255) NOT NULL, 
`firma` text NOT NULL, 
PRIMARY KEY (`firma_ID`) 
) ENGINE=MyISAM ;"
;
   
//ejecuto la sentencia
   
mysql_query($sql);

?> 
<?php
mysql_free_result
($Recordset1);
?>
el tema es que no se como ponerlo para que sea el numero de la id
le he dado mil vueltas pero na
espero que me ayudes gracias