IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Requêtes MySQL Discussion :

fonction postgresql


Sujet :

Requêtes MySQL

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Novembre 2003
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2003
    Messages : 5
    Par défaut fonction postgresql
    je voudrais faire une fonction (sous postgresql) qui recherche un patient et pour cela elle reçoit en parametre le id_patient (clef primaire) pour ensuite
    compléter un formulaire html qui reprendra les infos du patient .
    dans ce formulaire html j'aurais une zone qui recevra le numéro patient et quand je clik sur le bouton "rechercher"
    ce numéro patient sera passé en parametre a la fonction
    puis la fonction reprendra les infos (nom, prénom,...) puis compléter le formulaire
    ma base de données tourne sous postgresql et je fais mon site en php

  2. #2
    Membre chevronné
    Inscrit en
    Octobre 2003
    Messages
    266
    Détails du profil
    Informations forums :
    Inscription : Octobre 2003
    Messages : 266
    Par défaut
    Bonjour,

    Tu peux simplement le faire en PHP. Exemple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <html>
    <body>
    <form action="test.php">
    <?php
     
    $conn_string = "host=localhost dbname=ta_base  user=ton_user password=ton_password";
    $dbconn = pg_connect($conn_string);
     
    $result = pg_exec($dbconn ,"SELECT id, nom, prenom FROM ta_table WHERE id='$search_id';" );
    if($result==false) 
    {	
    	echo "Message d'erreur: ".pg_errormessage($dbconn);	
    } else {		
    	$res=pg_fetch_array($result);
       $id_patient = $res[0];
    	$nom_patient = $res[1];
    	$prenom_patient = $res[2];
    }
     
    pg_close ($dbconn);
    ?>
     
    <input type="text" name="search_id" value="<? print $id_patient; ?>"></input>
    <input type="submit">
    <input type="text" name="nom" value="<? print $nom_patient; ?>"></input>
    <input type="text" name="prenom" value="<? print $prenom_patient; ?>"></input>
    </form>
    </body>
    </html>
    C'est tout !

    Avec ce code, tu as un formulaire avec un champ id que tu remplis, puis en cliquant sur le bouton submit, cela remplis automatiquement les champs nom & prenom.

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Novembre 2003
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2003
    Messages : 5
    Par défaut qu'est ce qui ne va pas sur ce code ????
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> PRENDRE RENDEZ - VOUS  </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD>
    <BODY>
    <form name "page1" method = "get" action = "rechpat.php">
    <P align = "center"> <font face = "verdana" color = "red" size ="6">RENDEZ-VOUS</font> <BR> <BR>   
    <HR size=2 align=left width="100%" 
    <BR> <BR>   
    <BODY BGCOLOR="#6699CC">
     
     
    <?php 
     
    $conn_string = "host=localhost dbname=polyclinique  user=mous password=mousss"; 
    $dbconn = pg_connect($conn_string); 
     
    $result = pg_exec($dbconn ,"SELECT id_patient, nom_patient, pre_patient,adr_patient, sexe_pat, statut_pat,date_inscription FROM patient WHERE id_patient='$search_id';" ); 
    if($result==false) 
    {    
       echo "Message d'erreur: ".pg_errormessage($dbconn);    
    } else {       
       $res=pg_fetch_array($result); 
       $id_patient = $res[0]; 
       $nom_patient = $res[1]; 
       $pre_patient = $res[2]; 
       $adr_patient = $res[3];
       $sexe_pat = $res[4];
       $statut_pat = $res[5];
       $date_inscription = $res[6];
     
    } 
     
    pg_close ($dbconn); 
    ?> 
     
     
     
    <center>Entrez votre numéro de patient : <input type = "numeric"  name="search_id" value="<? print $id_patient; ?>" size ="10" align = "center"></center>
     
    <br> 
     
     
    <center><input type = "submit" name = "rechercher" value = "rechercher" align = "center" </center>
     
     
     
    <br> <br>
    <center>
     
    <table border=10>
    <tr>
    <td><B>Nom : </td>
    <td><input type = "text" ="text" name="nom" value="<? print $nom_patient; " size ="15" align = "center" >?><B/> </td>
    </tr>
     
    <tr>
    <td><B>Prénom : </td>
    <td><input type = "text" name="prenom" value="<? print $pre_patient; ?>" size ="15" align = "center"> </td>
    </Tr>
     
    <Tr>
    <td><B>Adresse : </td>
    <td><input type = "text" name ="adr patient" value="<? print $adr_patient; ?>" size ="30" align = "center"> </td>
    </tr>
     
    <tr>
    <td><B>Statut : </td>
    <td><input type = "text" name ="stat patient" value="<? print $statut_pat; ?>" size ="10" align = "center"> </td>
    </tr>
     
    <tr>
    <td><B>Sexe : </td>
    <td><input type = "text" name ="sexe patient" value="<? print $sexe_pat; ?>" size ="5" align = "center">  </td>
    </Tr>
     
    <tr>
    <td><B>Date inscription : </Td>
    <td><input type = "text" name ="date insc patient" value="<? print $date_inscription; ?>" size ="10" align = "center">  <Td>
    </tr>
     
    <br> 
     
    </form> 
     
    <BR> 
     
    <SELECT NAME="spécialisation">       
    <OPTION selected>
    <OPTION VALUE="dentiste">dentiste           
    <OPTION VALUE="gynécologie">gynécologie 
    <OPTION VALUE="o-r-l">o-r-l 
    <OPTION VALUE="orthodontie">orthodontie 
    <OPTION VALUE="ophtalmologie">Ophtalmologie 
    </SELECT> 
    </BODY>
     
    <SELECT NAME="horaire">horaire         
    <OPTION selected>
    <OPTION VALUE="H1">09H00-09H30            
    <OPTION VALUE="H2">09H30-10H00  
    <OPTION VALUE="H3">10H00-10H30  
    <OPTION VALUE="H4">10H30-11H00  
    <OPTION VALUE="H5">11H00-11H30  
    <OPTION VALUE="H6">11H30-12H00  
    <OPTION VALUE="H7">13H00-13H30  
    <OPTION VALUE="H8">13H30-14H00  
    <OPTION VALUE="H9">14H00-14H30  
    <OPTION VALUE="H10">14H30-15H00  
    <OPTION VALUE="H11">15H00-15H30 
    <OPTION VALUE="H12">15H30-16H00 
    </SELECT> 
     
     
    <SELECT NAME="medecin">
    <OPTION selected>
    <OPTION VALUE="med1">Dupont   
    <OPTION VALUE="med2">Lefevre
    <OPTION VALUE="med3">Van develde
    <OPTION VALUE="med4">El hassan  
     
    </SELECT> <br> 
    <br>
     
    <center>Date : <input type = "text" name ="date rdsvs" size ="10" align = "center"> <I>(ex : 10-10-2001)<I></center>  
    <br>
     
     
    <br>
    </center>
    <center><input type = "submit" name = "valider" value = "valider" align = "center"><input type = "submit" name = "effaer" value = "effacer" onclick = ""rechpatienthtml.nom patient" = """
    align = "center"></center>
    </BODY>
     
    </HTML>

    Modéré par Stessy
    Ajout de balises [code]
    Prière de lire les règles du forum

    Merci

  4. #4
    Membre chevronné
    Inscrit en
    Octobre 2003
    Messages
    266
    Détails du profil
    Informations forums :
    Inscription : Octobre 2003
    Messages : 266
    Par défaut
    Je ne l'ai pas testé mais à vu de nez, ta balise de fermeture de formulaire (</FORM>) ne devrait pas être en plein milieu de ton code mais à la fin de ton formulaire, c'est à dire entre la balise submit et le </BODY>.

    (C'est plus lisible....)

Discussions similaires

  1. Réponses: 0
    Dernier message: 19/04/2009, 11h56
  2. [PostgreSQL] Calculs sous PHP ou dans fonctions PostgreSQL
    Par ilalaina dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 22/09/2008, 08h20
  3. fonction postgresql qui delete un enr
    Par access dans le forum Requêtes
    Réponses: 1
    Dernier message: 16/11/2003, 14h44
  4. fonction postgresql qui delete un enr
    Par access dans le forum PostgreSQL
    Réponses: 1
    Dernier message: 16/11/2003, 14h44
  5. fonction postgresql
    Par access dans le forum PostgreSQL
    Réponses: 3
    Dernier message: 10/11/2003, 06h33

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo