|
|
PHP Quellcode |
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 |
<html><head> <title>AJAX PHP Beispiel mit Select</title> <script type="text/Javascript"> <!-- function sendRequest() { try { req = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { //Kein AJAX Support } req.onreadystatechange = handleResponse; id = document.getElementById('dropdown').value; req.open('get', 'func.php?s='+ id); req.send(null); } function handleResponse() { if ((req.readyState == 4) && (req.status == 200)) { document.getElementById('select2').innerHTML = req.responseText; } } //--> </script> </head> <body> <p />Wählen Sie einen Eintrag aus um den Inhalt zu laden <p /><select id="dropdown" onChange="sendRequest()"> <? include 'connect.php'; // Hier die Verbindung zur Datenbank herstellen $result = mysql_query("SELECT land_id,land_bezeichnung FROM `Laender`; "); while($row = mysql_fetch_object($result)) { echo '<option value="'.$row->land_id.'">'.$row->land_bezeichnung.'</option>'; } ?> </select> <div id="select2"></div> </body></html> |
|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 |
<? echo '<selct name="bundesland">'; $result = mysql_query("SELECT bland_id,bland_bezeichnung FROM `Bundesland` WHERE `land_id` = $_GET[s]; "); while($row = mysql_fetch_object($result)) { echo '<option value="'.$row->bland_id.'">'.$row->bland_bezeichnung.'</option>'; } echo '</select>'; ?> |
|
|
Source code |
1 |
$result = mysql_query("SELECT land_id,land_bezeichnung FROM `Laender`; ")or die('fehler in sql abfrage');
|
|
|
PHP Quellcode |
1 |
echo 'die tabelle hat '.mysql_num_rows($result).' eintraege'; |
|
|
PHP Quellcode |
1 2 3 4 5 6 |
<? $result = mysql_query("SELECT * FROM `Laender`; "); while($row = mysql_fetch_array($result)) { print_r($row); }?> |
|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 |
<? require ('.htmysql'); include 'dblib.inc'; // Hier die Verbindung zur Datenbank herstellen //Inhalte laden $result = mysql_query("SELECT gb_id, gb_mail, gb_url FROM `j4u_gb` WHERE `gb_id` = $_GET[s]; "); while($row = mysql_fetch_object($result)) { echo '<p /><b>'.$row->gb_mail.'</b><br />'.$row->gb_url; } ?> |
Quoted from ""d0nUt""
nein, wenn du ein <form> drumherum hast und das select einen namen hat, funktionierts auch so.

