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
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Les pages du club</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<!-- Masqué pour les anciens navigateurs
//-->
<Script Language="Javascript">
function saisie()
{
if (document.valbourse.valb.value !=""){
var m = document.valbourse.valb.value;
if (/^\d+(\.\d+)?$/.test(m)){
document.valbourse.valb.value = parseFloat(m).toFixed(2);
document.valbourse.newval.value = document.valbourse.valb.value;
}
else {
alert('Montant saisi incorrect!');
exit;
}
}
}
// -->
</SCRIPT>
<?php
$dbhost = "127.0.0.1";
$user = "root";
$password = "";
$usebdd = "bddbea";
$connexion = mysql_connect($dbhost,$user,$password);
if (!$connexion) {
echo "Impossible d'effectuer la connexion";
exit;
}
//sélection de la BDD
$db = mysql_select_db("$usebdd", $connexion);
if (!$db) {
echo "Impossible de sélectionner cette base données";
exit;
}
$resultat_sql = mysql_query("SELECT * FROM beavalbourse",$connexion);
$nombreligne = mysql_num_rows($resultat_sql);
$i = 0;
$montant = 0;
while ($i<$nombreligne)
{
$valeur = mysql_result($resultat_sql,$i,"vb_Valeur");
$Mydate = mysql_result($resultat_sql,$i,"vb_Date");
$a = substr($Mydate, 0, 4);
$m = substr($Mydate, 5, 2);
$j = substr($Mydate, 8, 2);
$h = substr($Mydate, 11, 2);
$n = substr($Mydate, 14, 2);
$madate = $j.'/'.$m.'/'.$a.' à '.$h.':'.$n;
$i++;
}
?>
<DIV class=menu id=m1 style="LEFT: 150px; Top:55px">
<form name="valbourse" method="POST" action="le_club.php">
<table border=0>
<tr><td>Valeur du portefeuille au : <?php echo $madate;?>
<input type="text" name="valb" value="<?php echo number_format($valeur, 2, ',', ' ');?>" style="text-align:right; width:90px" onFocus=value="" onblur="saisie()">
<input type="submit" name="valid" value="OK"></td></tr>
<tr><td><input type="text" name="newval" value=""></td></tr>
</table>
</form>
<?php
if(isset($_POST['newval'])) $newval=$_POST['newval'];
else $newval="";
if(!empty($_POST['newval']))
{
$date=date("Y-m-d H:i");
$sql = "TRUNCATE TABLE beavalbourse";
mysql_query($sql) or die(mysql_error());
$sqla = "INSERT INTO beavalbourse(vb_Valeur, vb_Date)
VALUES('$newval','$date')";
mysql_query($sqla) or die('Erreur SQL !'.$sqla.'<br>'.mysql_error());
}
else
{ echo "tata";
}
?> |
Partager