liste déroulante avec postgresql + php
	
	
		Bonjour,
j'essaie en vain de lister le contenu d'un champ d'une table. Je suis débutante. j'ai mis mon code ci-dessous si quelqu'un pouvait m'aider !!!! 
merci
	Code:
	
| 12
 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
 
 |  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Mon premier script PHP !</title>
</head>
 
<body>
 
 
<form>
<select name="mac">
<?php
// Connexion, sélection de la base de données
$dbconn = pg_connect("host=localhost port=5432 dbname=toto user=tata password=titi")
or die('Connexion impossible : ' . pg_last_error());
 
$sql = 'SELECT machine FROM machine';
$result = pg_query($sql) or die('Échec requête : ' . pg_last_error());
?>
<select name="machine" id="machine">
<?php
while ($ligne = pg_fetch_array($result, null, PGSQL_ASSOC))
{
'<option value="'.$ligne['machine'].'">'.$ligne['machine'].'</option>';
} 
?>
</select>
<?php
// Libère le resultset
pg_free_result($result);
 
// Ferme la connexion
pg_close($dbconn);
?>
</select>
</form>
 
</body>
</html> |