Dreamweaver - problema con consulta en dos tablas mysql relacionadas

 
Vista:
sin imagen de perfil

problema con consulta en dos tablas mysql relacionadas

Publicado por javier (1 intervención) el 07/03/2015 02:32:59
Hola buenas noches a todos... estoy comenzando con dreamweaver, mysql y php pero me he conseguido con una barrera insalvable debido a mi poco conocimiento, espero que alguno de ustedes me pueda ayudar...

Resulta que tengo una base de datos con varias tablas, ellas son: datos estudiantes, datos representantes, datos academicos, datos medicos; en mysql intente hacer la relacion entre ellas insertado tres claves foraneas en la tabla datos estudiantes, estas claves foraneas fueron el id del representante, el id de los datos academicos y el id de los datos medicos (todos ellos autoincrementales); en fin cuando creo un registro nuevo, todas las tablas generan un valor que comparten ese valor es el autoincremental... Cree un juego de registros y pude extraer hacia un formulario la informacion de la tabla de estudiantes por medio de su numero de cedula, pero en es mismo formulario tambien tengo que extraer los datos correspondientes a sus representantes, datos medicos y academicos que como dije comparten todos el valor auto incremental... he pasado horas trando de solucionarlo y buscando informacion en la web y no he podido solocionar... aca les envio el codigo a ver si agien puede darme una mano, estaria muy agradecido...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php require_once('Connections/local.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;
}
}
 
$varcedula_consulta = "-1";
if (isset($_GET['ciestudiantes'])) {
  $varcedula_consulta = $_GET['ciestudiantes'];
}
mysql_select_db($database_local, $local);
$query_consulta = sprintf("SELECT * FROM datosestudiantes WHERE ciestudiantes = %s", GetSQLValueString($varcedula_consulta, "int"));
$consulta = mysql_query($query_consulta, $local) or die(mysql_error());
$row_consulta = mysql_fetch_assoc($consulta);
$totalRows_consulta = mysql_num_rows($consulta);
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder