1. Trang chủ
  2. » Công Nghệ Thông Tin

Hướng dẫn Connect to database ppt

6 259 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 6
Dung lượng 37,46 KB

Nội dung

Hướng dẫn Connect to database <head> <title> COPYRIGHT BY MRRO WINDAK UPGRADE </title> </head> <body bgcolor="#008080"> <p align="center"> <b> CONNECT TO DATABASE </b> </p> <p align="center"><i><b>Upgraded by Windak </b> </i></p> <p align="center">Version 2.0 </p> <p align="center"> </p> <! T?o table ?? query > <form action=<? echo $HTTP_SERVER_VARS['PHP_SELF'] ?> method=post> <table align="center" border=3 cellpadding="3" cellspacing="2" bordercolor="#ffffff" width="420"> <tr> <td bgcolor="#00FFFF" width="72"><b>Server</b> </td> <td width="329"><input name=server value="<? echo $server ?>" size=30 style="HEIGHT: 22px; WIDTH: 321px"></td></tr> <tr> <td bgcolor="#00FFFF" width="72"><b>Username</b> </td> <td width="329"><input name=username value="<? echo $username ?>" size=30 style="HEIGHT: 22px; WIDTH: 321px"></td></tr> <tr> <td bgcolor="#00FFFF" width="72"><b>Password</b> </td> <td width="329"><input name=password value="<? echo $password ?>" size=30 style="HEIGHT: 22px; WIDTH: 321px"></td></tr> <tr> <td bgcolor="#00FFFF" width="72"><b>Database</b> </td> <td width="329"><input name=database value="<? echo $database ?>" size=30 style="HEIGHT: 22px; WIDTH: 321px"></td></tr> <tr> <td bgcolor="#00FFFF" width="72"><b>Table</b> </td> <td width="329"><input name=table value="<? echo $table ?>" size=30 style="HEIGHT: 22px; WIDTH: 321px"></td></tr> <tr> <td bgcolor="#00FFFF" colspan="2" width="411" align="right"><p align="center"> <input type="submit" value="Select Column" name=select style="float: left"><input name="StrColumn" size="15" value="<? echo $StrColumn ?>"> <p align="right"> where <input type="text" name="column2" size="15" value="<? echo $column2 ?>"> = <input type="text" name="value2" size="17" value="<? echo $value2 ?>"></td></tr> <tr> <td bgcolor="#00FFFF" colspan="2" width="411" align="right"><p> <input type="submit" value="Update table" name=update style="float: left">set <input type="text" name="column1" size="15" value="<? echo $column1 ?>"> = <input type="text" name="value1" size="17" value="<? echo $value1 ?>"><p align="right">where <input type="text" name="column2" size="15" value="<? echo $column2 ?>"> = <input type="text" name="value2" size="17" value="<? echo $value2 ?>"></td></tr> <td valign="top" bgcolor="#00FFFF" width="72"><b>SQL Command:</b> </td> <td width="329"><textarea cols=30 name=query rows=5 style="HEIGHT: 86px; WIDTH: 322px" wrap=virtual><? echo stripslashes($query) ?></textarea></td> <tr> <td align="right" bgcolor="#00FFFF" colspan="2" width="411"> <input type="submit" name=ListDB value="LIST DATABASE" style="float: left"> <input type="submit" name=submit value="Query"></td> </tr> </table></form> <! T?o command > <? //Khoi tao $self=$HTTP_SERVER_VARS['PHP_SELF']; $query=stripslashes($query); echo $query; if (isset($HTTP_POST_VARS['submit']) || isset($HTTP_POST_VARS['select']) || isset($HTTP_POST_VARS['update']) || isset($HTTP_GET_VARS['tb'])) { //Thiet lap Query if (isset($HTTP_GET_VARS['tb'])) { $database=$HTTP_GET_VARS['db']; $username=$HTTP_GET_VARS['user']; $password=$HTTP_GET_VARS['pass']; $server=$HTTP_GET_VARS['server']; $table=$HTTP_GET_VARS['tb']; $query = "Select * from $table"; echo $query; } $conn = mysql_connect("$server","$username","$password"); if (!conn) { echo mysql_error(); exit; } if (isset($HTTP_POST_VARS['select'])) { if (($column2)&&($value2)) { $query="Select $StrColumn from $table where $column2 = '$value2'"; } else $query="Select $StrColumn from $table" ; } else if (isset($HTTP_POST_VARS['update'])) { if (($column2)&&($value2)&&($column1)&&($value1)) { $query="Update $table set $column1='$value1' where $column2='$value2'"; } else die("PLEASE CORRECT YOUR INPUT"); } //Chay mysql_select_db($database); $res=mysql_query($query); echo " <table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" \"border- collapse: collapse\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\">" ; echo "<tr>"; $ncols = mysql_num_fields($res); while($i<$ncols) { $meta = mysql_fetch_field ($res); echo "<td> <b>". $meta->name ."</b> </td>" ; $i++; } echo "</tr>"; while($data=mysql_fetch_array($res)) { echo("<tr>"); for($i=0; $i<$ncols; $i++) { echo "<td> ". $data[$i] ." </td>"; } echo("</tr>"); } mysql_free_result($res); } //Click ListDB else if (isset($HTTP_POST_VARS['ListDB'])) { $conn = mysql_connect("$server","$username","$password"); $db_list = mysql_list_dbs($conn); if (!$db_list) { echo mysql_error(); exit; } while ($row = mysql_fetch_object($db_list)) { $rdata = $row->Database ; $tb_list = mysql_list_tables($rdata); if (!$tb_list) { echo "$rdata "; } else echo "$rdata "; } } else if (isset($HTTP_GET_VARS['db'])) { //Get info $database=$HTTP_GET_VARS['db']; $username=$HTTP_GET_VARS['user']; $password=$HTTP_GET_VARS['pass']; $server=$HTTP_GET_VARS['server']; //Test permission if (!mysql_connect("$server","$username","$password")) { echo mysql_error(); exit; } $tb_list = mysql_list_tables($database); // Okie List while ($row = mysql_fetch_row($tb_list)) { echo "$row[0] "; } mysql_free_result($tb_list); } ?> </table> </body> </html> . Hướng dẫn Connect to database <head> <title> COPYRIGHT BY MRRO WINDAK UPGRADE </title>. <body bgcolor="#008080"> <p align="center"> <b> CONNECT TO DATABASE </b> </p> <p align="center"><i><b>Upgraded. bgcolor="#00FFFF" width="72"><b> ;Database& lt;/b> </td> <td width="329"><input name =database value="<? echo $database ?>" size=30 style="HEIGHT:

Ngày đăng: 31/07/2014, 18:20

TỪ KHÓA LIÊN QUAN

w