oto mój skrypt
var xmlHttp function showHist(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="getajax.php" url=url+"?q="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint").innerHTML=xmlHttp.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
test.php
<?php header("Content-type: text/html; charset=iso-8859-2"); echo'<script src="ajax.js"></script>'; $q=$_GET["q"]; mysql_connect('localhost', 'test', 'test') or die('Błąd połączenia z bazą danych: '.mysql_error()); mysql_selectdb('test') or die('Błąd wyboru bazy danych: '.mysql_error()); ?> <html> <table> <tr> </tr> </html> <?php switch ($q) { case dzis: $sql = 'SELECT * FROM `proj` WHERE `data` LIMIT 0, 30 '; $result=mysql_query($sql); while($row = mysql_fetch_array($result)) { echo("<tr>"); echo("</tr>"); } break; case wczoraj: echo('no i chuj'); break; } ?>
test_mysql.php
<?php echo'<script src="ajax.js"></script>'; echo('<form> Opcje: { } ?>
Jak się z tym uporać ? z góry dziękuje za pomoc