Scusa non ho ben capito dove devo mettere le cose
io ho scritto questo ma è sbagliato, saresti così gentile da postarmi la cosa corretta così cerco di capire bene come funziona? Grazie mille
codice:<?php header('Content-Type: text/xml'); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Post</title> </head> <body> <div id="xmldata"></div> <script type="text/javascript"> function readyAJAX() { try { return new XMLHttpRequest(); } catch(e) { try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) { try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) { return "Hai bisogno di un altro browser."; } } } } function mostraInfo(data) { var requestObj = readyAJAX(); var url = "mostra_utenti.php"; var params = "q=" + data; requestObj.open("POST",url,true); requestObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); requestObj.send(params); var serverResponse = requestObj.responseXML; var header = serverResponse.getElementsByTagName("user"); htmlString = "<table><tr><th>Nome</th><th>Cognome</th><th>Username</th><th>Password</th><th>Email</th></tr>"; for (i=0; i<header.length; i++) { htmlString += "<tr>"; if (window.ActiveXObject) { htmlString += "<td>" + header[i].childNodes[0].text + "</td>"; htmlString += "<td>" + header[i].childNodes[1].text + "</td>"; htmlString += "<td>" + header[i].childNodes[2].text + "</td>"; htmlString += "<td>" + header[i].childNodes[3].text + "</td>"; htmlString += "<td>" + header[i].childNodes[4].text + "</td>"; } else { htmlString += "<td>" + header[i].childNodes[0].textContent + "</td>"; htmlString += "<td>" + header[i].childNodes[1].textContent + "</td>"; htmlString += "<td>" + header[i].childNodes[2].textContent + "</td>"; htmlString += "<td>" + header[i].childNodes[3].textContent + "</td>"; htmlString += "<td>" + header[i].childNodes[4].textContent + "</td>"; } htmlString += "</tr>"; } htmlString += "</table>"; document.getElementById('info').innerHTML = htmlString; } </script> <form> Seleziona Dipendente: <select name="posti" onChange="mostraInfo(this.value)"> <?php $db_host = "localhost"; $db_user = "administrator"; $db_password = "administrator"; $db_database = "ticket"; //Seleziono quelli che sono i dipendenti $connessione = mysql_connect($db_host,$db_user,$db_password); mysql_select_db($db_database, $connessione); $query = "SELECT * FROM teatro WHERE disp='true'"; $result = mysql_query($query); while($riga = mysql_fetch_array($result)){ echo "<option value='$riga[id]'>fila $riga[fila] posto$riga[posto]</option>"; $xml = new DomDocument('1.0'); $info = $xml->createElement('informations'); $info = $xml->appendChild($info); while ($row = mysql_fetch_array($result)) { $firstname = $xml->createElement('firstname'); $firstname = $info->appendChild($firstname); $value = $xml->createTextNode($row['user_firstname']); $value = $firstname->appendChild($value); $lastname = $xml->createElement('lastname'); $lastname = $info->appendChild($lastname); $value = $xml->createTextNode($row['user_las tname']); $value = $lastname->appendChild($value); $username = $xml->createElement('username'); $username = $info->appendChild($username); $value = $xml->createTextNode($row['user_username']); $value = $username->appendChild($value); $password = $xml->createElement('password'); $password = $info->appendChild($password); $value = $xml->createTextNode($row['user_password']); $value = $password->appendChild($value); $email = $xml->createElement('email'); $email = $info->appendChild($email); $value = $xml->createTextNode($row['user_email']); $value = $email->appendChild($value); } $output = $xml->saveXML(); } ?> </select> </form> <div id="info"></div> </body> </html>


Rispondi quotando