1
<form id= "Form1" Name= "Form1" action= "2.php" method= "Get" >The following tables are available in this database: <input type= "text" name= "Shuru" value= ""/> <input type= "Submit" Name= "sub" value= "Query" > </form>< ;?PHP/** * By:qingsong * DATE:2015/4/18 0018 * time:22:17*/Header(' Content-type:text/html;charset=utf-8 ');$jieshou= "Qingsong";Define("Connect", @mysql_connect("localhost", "root", "root"));//List table names//echo "database--". $jieshou. " <br/><br/> "; $dbs= @Mysql_list_tables("Qingsong",connect); $rows=mysql_num_rows($dbs); $i= 0; while($i<$rows) { $db _name[$i] =Mysql_tablename($dbs,$i); Echo $db _name[$i]." </br> " ; $i++; }
2
<?PHP/** * By:qingsong * DATE:2015/4/21 0021 * time:21:52*/ Header(' Content-type:text/html;charset=utf-8 ');@$conn=NewMysqli ("localhost", "root", "root");if($conn->connect_error) die("Database connection failed.")$conn-connect_error);$shuru=$_get["Shuru"];functionChaxun ($shuru){ @$conn=NewMysqli ("localhost", "root", "root"); $conn->select_db ("Qingsong");$sql= "SHOW full COLUMNS from".$shuru";$result=$conn->query ($sql);if(!$result) die("Data query Failed");//$row _num= $result->num_rows;//$col _num= $result->field_count;//echo "number of rows: $row _num, number of columns: $col _num";Echo"<br/>";Echo"<table bordercolor= #4F88EF align=center border=1><tr>";//Table while($field=$result-Fetch_field ()) { Echo"<th>$field->name</th> ";//$field The Name property :}Echo"</tr>"; while($res=$result-Fetch_row ()) { Echo"<tr>"; foreach($res as $val) Echo"<th>$val</th> "; Echo"</tr>";}Echo"</table>";} Chaxun ($shuru);><input type= "button" onclick= "window.location.href= ' 4.php '" value= "View Data" >
<?PHP/** * By:qingsong * DATE:2015/4/21 0021 * time:22:39*/Header(' Content-type:text/html;charset=utf-8 ');$link=mysql_connect("localhost", "root", "root");if(!$link)Echo"The database is not connected successfully!";Else Echo"Database connection succeeded!<br/>";mysql_select_db("Qingsong",$link);//Select Database$q= "SELECT * from admin";//SQL query Statementsmysql_query("SET NAMES UTF8");$rs=mysql_query($q,$link);//Get Data Setif(!$rs){ die("Valid result!");}Echo"<table>";Echo"<tr><td>ID</td><td> Manage Accounts </td><td> gender </td><td> password </ Td><td> Registration date </td><td> Front vest </td></tr> "; while($row=Mysql_fetch_row($rs))Echo"<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td><td>$row[5]</td></tr> ";//Show DataEcho"</table>";Mysql_free_result($rs);//To close a data setEcho"<br/><br/> <a href=3.php?id=qingsong> back to </a>". "<br>";
Php+mysql Implementing output Print database table structure and output table contents