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
|
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
// configuration
$link = mysql_connect ($host,$user,$pass);
mysql_query("SET CHARACTER SET 'utf8';", $link)or die('Erreur: '.mysql_error());
// selection de la DB
mysql_select_db($db) or die ('Erreur: '.mysql_error());
?>
<form action="<? $_SERVER['PHP_SELF'] ?>" METHOD="post">
<table width="500" border="0" align="center">
<tr>
<td>
<?php
$select = 'SELECT * FROM livres ORDER BY ID ASC';
$result = mysql_query($select,$link) or die ('Erreur: '.mysql_error() );
$total = mysql_num_rows($result);
// si les information sont inserees on les extrait
// si on a récupéré un résultat on l'affiche.
if($total) {
?>
<form action="<? $_SERVER['PHP_SELF'] ?>" METHOD="post">
<select name="livre">
<?
while($row = mysql_fetch_array($result)) {
$livre = $row['livre'];
?>
<option><?php echo $livre; ?></option>
<?
} // fin de while
?>
</select>
<?
} // fin de if
else 'rien de rien';
?>
</td>
<td>
<?
// un test sur le livre qui a comme id = 1
$select1 = 'SELECT nbre_pages FROM livres WHERE id="1"';
$result1 = mysql_query($select1,$link) or die ('Erreur: '.mysql_error() );
$total1 = mysql_num_rows($result1);
// si les information sont inserees on les extrait
if($total1) {
while($row1 = mysql_fetch_array($result1)) {
$nbre_pages = $row1['nbre_pages'];
}
?>
<form>
<select size="1">
<option>de</option>
<?php
for ($i=1; $i<=$nbre_pages; $i++)
{
echo '<option>' .$i. '</font></option>';
}
?>
</td>
<td>
<select>
<option>a</option>
<?php
// cette j doit etre egale ou superieur a i
for ($j>=$i; $j<=$nbre_pages; $j++)
{
echo '<option>' .$j. '</font></option>';
}
?>
</select>
</td>
</tr>
</table>
</form>
<?
}
?> |
Partager