SlideShare une entreprise Scribd logo
Niveau débutant

       PHP & MYSQL




                  JABALLAH.Mourad
PRÉ REQUIS


   HTML

            Programmation(esprit+c)



Base des données(Conception,sql,..)
PLAN DE LA FORMATION
1-INTRODUCTION & DEFINITIONS
2-OUTILS DE DEVELOPPEMENT
3-LANGAGE PHP
4- MYSQL
5- INTERACTION PHP & MYSQL
SITE WEB STATIQUE ?
SITE WEB DYNAMIQUE ?
       PHP ?
Php
VOULEZ VOUS ENCORE RESTEZ
        STATIQUE?

  ATTACHEZ VOS CEINTURE!
   EN VA VOLER AU MONDE
        DYNAMIQUE !
PRÉPARONS NOS BAGAGE ALORS ?
Php
•Le fichier contenant le code PHP doit avoir l’extension PHP.
•Le scripte PHP doit être délimité par les balises < ? et ?>.
•Le fichier PHP doit être enregistré dans le répertoire
d’hébergement du serveur Apache WWW.
•Pour exécuter un fichier PHP il faut aller à son adresse web
local
exemples :
 http://localhost/.... Ou http://127.0.0.1/...
http://localhost/tpphp/tp1.php
Un proverbe français :



Pour apprendre à nager il faut se
           ---------- !
Php
Variable                     Signification
                             S'utilise lorsque l'attribut
$_POST['donnee']             METHOD du formulaire est
                             POST.
                             S'emploie lorsque l'attribut
                             METHOD du formulaire est GET
$_GET['donnee']
                             ou bien lorsque les données sont
                             envoyer dans l’URL.


Exemples :
Echo($_POST[‘nom’])
http://www.votresite.com/index.php?nom=ali&prenom=mohamad
Echo($_GET[‘nom’])
Echo(‘’ texte…’’) ;
Echo($i) ;
Echo(‘’ texte…$var’’) ;
<?php
if(condition)
{
instruction(s);
}else
{     instruction(s);
}
?>
for (compteur; condition; modification du compteur)
{
 liste d'instructions
}
while (condition réalisée)
{
 liste d'instructions
 }
Php
MySQL dérive directement de SQL (Structured Query Language) qui est un
langage de requête vers les bases de données exploitant le modèle
relationnel.
Il en reprend la syntaxe mais n’en conserve pas toute la puissance puisque de
nombreuses fonctionnalités de SQL n’apparaissent pas dans MySQL
(sélections imbriquées, clés étrangères…)
Le serveur de base de données MySQL est très souvent utilisé avec le langage
de création de pages web dynamiques : PHP. Il sera discuté ici des commandes
MySQL utilisables via PHP dans les conditions typiques d’utilisation dans le
cadre de la gestion d’un site personnel hébergé gratuitement (par exemple
sur Free.fr).




     Base de                 Script                            Page
                 MySQL                        HTTP
     données                  PHP                              HTML

                                                               Client
Personnes                                         Bibliothèque
nom      prénom      adresse           téléphone           nom             Dernierlivre
Martin   Pierre      7 allée des vers 0258941236           Dupond          Robinson
Dupond   Jean        32 allé Poivrot   0526389152          Jospin          Faust
                                                           Martin          Misère


                  SELECT Personnes.prénom, dernierlivre
                  FROM Personnes, Bibliothèque
                  WHERE Personnes.nom = Bibliothèque.nom



                            prénom          Dernierlivre
                            Jean            Robinson
                            Pierre          Misère
Personnes

nom      prénom      adresse            téléphone
Martin   Pierre      7 allée des vers 0258941236
Dupond   Jean        32 allé Poivrot    0526389152
Dupond   Marc        8 rue de l’octet   0123456789




                     SELECT nom, prénom
                     FROM Personnes
Etudient


Num   Prenom       age    moy
1     ali          22     15.50
2     fawzi        20     12.50
3     salwa        19     16.33
INSERT INTO
votre_table (nom,prenom,adresse)
VALUES ('Dupond','Michel','150 rue de la marne')
DELETE FROM votre_table WHERE nom = 'Martin'
UPDATE Client
SET nom='Durand',
prenom='Henry' WHERE
adresse='12 rue de la
marne';
Mariage
<?php
$connection =
mysql_connect("localhost","root","");
mysql_select_db("test");
$res=mysql_query("select * from etudient");
while($enr=mysql_fetch_array($res))
{
echo $enr['prenom']."<br>";
}
APPLICATION
UN PETIT DICTIONNAIRE
      EN LIGNE !
Notre base de données(dico)

             Table mots
motfr          moten      catg
Aller          go         verbe
Ordinateur     computer   Nom
Recherche
<html>
<head>
<title>recherche</title>
</head>
<body>
veuillez entrer le mot à rechercher:
<form method="POST" action="find.php">
         <input type="text" name="mot" size="20">
         <p>
         <input type="submit" value="Envoyer" name="B1">

          <input type="reset" value="Rétablir" name="B2">
          </p>
</form>
</body>
</html
<?php
$m=$_POST[‘mot’];
$connection = mysql_connect("localhost","root","");
mysql_select_db(“dico");
$res=mysql_query("select * from mots where motfr=‘$m’ ");
$num = mysql_num_rows($result);
If( $num==0)
{
Echo ‘’ mot introuvable…’;
}
Else
{
while($enr=mysql_fetch_array($res))
{
echo $enr[‘motfr'].’:(’. $enr[‘catg'].’):’.$enr[‘moten'];
}
}
?>
Ajouter un mot




C’est à vous !

Contenu connexe

PDF
Compteur de visites
PPTX
Initiation à la fouille de texte - formation AJPro
PDF
Silent install-kixtart office2010
PDF
PHP #6 : mysql
PPTX
Theme 9(bis)
PPTX
JABES 2016 - Vers des transferts réguliers améliorés
PDF
Commande dos
PPT
Réalisation d'un mashup de données avec DSS de Dataiku et visualisation avec ...
Compteur de visites
Initiation à la fouille de texte - formation AJPro
Silent install-kixtart office2010
PHP #6 : mysql
Theme 9(bis)
JABES 2016 - Vers des transferts réguliers améliorés
Commande dos
Réalisation d'un mashup de données avec DSS de Dataiku et visualisation avec ...

En vedette (20)

PPTX
Php & My Sql
PDF
Javascript in a continuous integration environment
PDF
PHP MySQL database connections
ODP
Présentation de PHP 5.4 [FR]
PPT
SQL -PHP Tutorial
PDF
Bases de PHP - Partie 1
PDF
Une application en deux heure - PHP Québec Janvier 2009
PPTX
PHP (Partie II) Par Mahdi Ben Alaya
PPTX
Php & My Sql
PDF
JavaScript pour le développeur Java
PDF
script site e-commerce -php
PPTX
Examination Hall Allocation
PDF
Intégration Continue PHP avec Jenkins CI
PDF
Développement d'un site web de E-Commerce avec PHP (Première Partie)
PDF
Un exemple élémentaire d'application MVC en PHP
PPTX
CRG-25eme-2014
PPTX
Vih perio implantes22
PDF
Repaso mates 2º
PDF
Internet et le recrutement
Php & My Sql
Javascript in a continuous integration environment
PHP MySQL database connections
Présentation de PHP 5.4 [FR]
SQL -PHP Tutorial
Bases de PHP - Partie 1
Une application en deux heure - PHP Québec Janvier 2009
PHP (Partie II) Par Mahdi Ben Alaya
Php & My Sql
JavaScript pour le développeur Java
script site e-commerce -php
Examination Hall Allocation
Intégration Continue PHP avec Jenkins CI
Développement d'un site web de E-Commerce avec PHP (Première Partie)
Un exemple élémentaire d'application MVC en PHP
CRG-25eme-2014
Vih perio implantes22
Repaso mates 2º
Internet et le recrutement
Publicité

Similaire à Php (20)

PDF
Php 2 - Approfondissement MySQL, PDO et MVC
PDF
Présentation de DBAL en PHP
PDF
Présentation de DBAL en PHP (Nantes)
PDF
presentationatelierphpprt2-140314143938-phpapp02.pdf
PPTX
La 2ème partie de la présentation PHP
PDF
Mpdf 3
PPT
Php mysql cours
 
PPTX
PPTX
Ce cours est un tutoriel de programmation PHP en accéléré.
PDF
Mpdf 8
ODP
Cours PHP 4/4 - Pierre Rudloff
ODP
Cours PHP 4
PDF
Php Data Object
PPT
introduction au SQL et MySQL
PPT
PHP - fonctions mysql
PPT
Créer une base de données avec MySQl.ppt
PDF
Mpdf 5
PPT
cours programmation web tres utile PHP1.ppt
PDF
Mpdf 12
PDF
Mpdf 7
Php 2 - Approfondissement MySQL, PDO et MVC
Présentation de DBAL en PHP
Présentation de DBAL en PHP (Nantes)
presentationatelierphpprt2-140314143938-phpapp02.pdf
La 2ème partie de la présentation PHP
Mpdf 3
Php mysql cours
 
Ce cours est un tutoriel de programmation PHP en accéléré.
Mpdf 8
Cours PHP 4/4 - Pierre Rudloff
Cours PHP 4
Php Data Object
introduction au SQL et MySQL
PHP - fonctions mysql
Créer une base de données avec MySQl.ppt
Mpdf 5
cours programmation web tres utile PHP1.ppt
Mpdf 12
Mpdf 7
Publicité

Plus de karousn (9)

PDF
Modl2 rap pfe_esti
PDF
Assemblage par vues de composants
PDF
2009 m1 ensta_projet_bases_de_donnees
DOC
Template _rapport_pfe - new_copi
PDF
Modl2 rap pfe_esti
PDF
Assemblage par vues de composants
PDF
2009 m1 ensta_projet_bases_de_donnees
DOC
Template _rapport_pfe - new
PDF
Javascript
Modl2 rap pfe_esti
Assemblage par vues de composants
2009 m1 ensta_projet_bases_de_donnees
Template _rapport_pfe - new_copi
Modl2 rap pfe_esti
Assemblage par vues de composants
2009 m1 ensta_projet_bases_de_donnees
Template _rapport_pfe - new
Javascript

Php