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
   |  
<?php
    mysql_connect('localhost', 'momo', 'momo')or die(mysql_error());
    mysql_select_db('test') or die(mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
    <head>
        <script type="text/javascript" src="xmlhttprequest.js"> </script>
        <script type="text/javascript">
 
            function request() {
 
	            var xhr = getXMLHttpRequest();
 
	            xhr.onreadystatechange = function() {
		        if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			    readData(xhr.responseText);
                            document.getElementById("loader").style.display = "none";
		        } else if (xhr.readyState < 4) {
			    document.getElementById("loader").style.display = "inline";
		        }
	            };
 
	            xhr.open("POST","blog_blog.php",true);
                    xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                    var valeur = document.getElementById("text").value;
	            xhr.send("variable="+valeur);
            }
 
            function readData(oData) {
	           oData;
            }
 
        </script>
    </head>
 
    <body>
 
 
        <div id="loader" style="display:none"><img src="image.gif" alt="Patienter svp" /> </div>
        <div id="comment" style="border: 1px solid #333; width: 400px; padding:20px; margin:0 auto;margin-top:10px; ">
 
	    <?php
                 
                $query = "SELECT prenom FROM reference";
                $res = mysql_query($query) or die(mysql_error());
                while($row = mysql_fetch_assoc($res)){
                        echo "<div style='background:red; margin:10px;'>".$row["prenom"]."</div>";
                }
            ?>
	</div>
 
 
                 <input type="text" name="text" id="text"  onclick='request()'/>
 
 
 
 
    </body>
             <?php
                 mysql_close();
             ?>
</html> | 
Partager