host:<inputType="Text"Name="Host"Id="Host"style="width:100px;" Value="127.0.0.1"/> user:<inputType="Text"Name="User"Id="User"style="width:100px;" Value="Root"/> password:<inputType="Text"Name="Password"Id="Password"style="width:100px;" Value="12345"/> database:<inputType="Text"Name="Database"Id="Database"style="width:100px;" Value="Ajax"/> <inputType="Submit"Id="button"Value="link"/> <SelectName=' Sldd 'style='width:100px; DisplayNone;' Id="Sldd"> <optionValue=' table 'selected> data Table </option> </Select> <TableBorder="1"cellpadding="3"cellspacing="1"Id="tab"> <TRId="TR1"> <TDId="TD1"> Database field </TD> </TR> <TRId="TR2"> <TDId="TD2"> Database Information </TD> </TR> </Table> <ScriptType="Text/javascript"charset="Utf-8"Src="Jquery-2.1.4.min.js"></Script> <Script> $ ("#button"). Click (function () {var host=$ ("#host"). Val ();
var user=$ ("#user"). Val ();
var password=$ ("#password"). Val ();
var database=$ ("#database"). Val ();
Die ();
var my_data= ""; My_data= ' {"host": "' +host+ '", "User": "' +user+ '", "Password": "' +password+ '", "Database": "' +database+ '", "Code": "1"} '
; $.ajax ({url: "ajax_php.php", type: "POST", data:{trans_data:my_data}, DAT
Atype: ' JSON ', error:function () {alert ("Error loading XML document");
}, Success:function (data,status) {//If PHP success is invoked for (Var i=0;i<data.length;i++) {
$ (' #sldd '). Show ();
$ (' #sldd '). Append (' <option value= "' +data[i]+ '" > ' +data[i]+ ' </option> ');
}
}
});
}); </Script> <ScriptType="Text/javascript"> $ (document). Ready (function () {$ ("#sldd"). Bind ("Change", function () {if ($ (). Val () ==0) {
Alert (111);
else{var host=$ ("#host"). Val ();
var user=$ ("#user"). Val ();
var password=$ ("#password"). Val ();
var database=$ ("#database"). Val ();
Die ();
var my_data= ""; My_data= ' {"host": "' +host+ '", "User": "' +user+ '", "Password": "' +password+ '", "Database": "' +database+ '", "code":
"2", "Table": "' +$" (This). Val () + ' "}"; "Host": "127.0.0.1", "User": "root", "password": "12345", "Database": "Ajax"} $.ajax ({URL : "ajax_php.php", type: "POST", data:{trans_data:my_data}, DAT
Atype: ' JSON ', error:function () {alert ("Error loading XML document");
}, Success:function (data,status) {//If PHP success is invoked for (Var i=0;i<data.length;i++) {
$ (' #tr1 '). Append (' <td> ' +data[i]+ ' </td> ');
}
}
});
}
});
}); </Script>
<?php header (' content-type:text/html; Charset=utf-8 ');
$ar =array (' 0 ' =>1087, ' 1 ' =>1);
echo $arr =json_encode ($ar);
Echo ' <br> ';
Echo Print_r (Json_decode ($arr));
Die ();
$BK =$_post[' Trans_data ']; $BK = $backValue = ' {"host": "127.0.0.1", "User": "root", "password": "12345", "Database": "Yii", "Code": "2", "Table": "
Order "}";
$BK =json_decode ($BK, true);
if ($BK [' code '] = = 1) {$db = new mysqli ();
$db->connect ($BK [' Host '], $BK [' User '], $bk [' Password '], $BK [' database ']);
$query [0] = $db->query (' SET NAMES utf8 ');
$sql [0]= ' Show tables ';
$query [0]= $db->query ($sql [0]);
while ($rs =mysqli_fetch_array ($query [0])) {$result []= $rs;
} $db->close ();
foreach ($result as $k => $value) {$result 2[]= $result [$k][0];
Echo Json_encode ($result 2);
Die ();
} if ($BK [' code '] = = 2) {$db = new mysqli ();
$db->connect ($BK [' Host '], $BK [' User '], $bk [' Password '], $BK [' database ']);
$db->query (' SET NAMES utf8 '); $sql = "SELECT * from". $BK [' table ']. "
`";
$query = $db->query ($sql);
while ($rs = Mysqli_fetch_array ($query)) {$result [] = $rs;
} $i = 0;
foreach ($result [0] as $key => $value) {$i + = 1;
if ($i% 2 = 0) {$a [] = $key;
}} $query->free ();
$db->close ();
echo Json_encode ($a); }