首页 > 代码库 > 辅导日
辅导日
今天看了mysql,看完后又懵逼了...完全不会,而且新东西好多,晚上写代码都感觉稍微明白了一点...
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <?php $link = mysql_connect(‘localhost‘, ‘root‘, ‘admin‘); mysql_query(‘set names utf8‘); $databases = mysql_query(‘show databases‘); if(!$databases){ echo "执行失败,请参考:".mysql_error(); } else{ echo "执行成功!数据如下:"; while($res = mysql_fetch_array($databases)){ echo "<br>".$res[0]; echo " <a href=http://www.mamicode.com/‘mysql_tables.php?db={$res[0]}‘>查看表</a>"; } } ?> </body> </html>
<?php $db = $_GET[‘db‘]; $link = mysql_connect(‘localhost‘,‘root‘,‘admin‘); mysql_query(‘set names utf8‘); mysql_query("use $db"); $table = mysql_query(‘show tables‘); if(!$table){ echo "执行失败,请参考:".mysql_error(); } else{ echo "执行成功!数据如下:"; while($res=mysql_fetch_array($table)){ echo ‘<br>‘.$res[0]; echo " <a href = http://www.mamicode.com/mysql_table_struct.php?db=$db&table={$res[0]}>查看结构</a>"; echo " <a href = http://www.mamicode.com/mysql_table_data.php?db=$db&table={$res[0]}>查看数据</a>"; } } ?>
<?php $db = $_GET[‘db‘]; $table = $_GET["table"]; $link = mysql_connect(‘localhost‘,‘root‘,‘admin‘); mysql_query(‘set names utf8‘); mysql_query("use $db"); $struct = mysql_query("desc $table"); if(!$struct){ echo "执行失败,请参考:".mysql_error(); } else{ echo "执行成功!数据如下:"; echo "<table border=‘1‘>"; $field_count = mysql_num_fields($struct); echo "<tr>"; for($i=0; $i<$field_count; ++$i){ $file_name = mysql_field_name($struct,$i); echo "<td>".$file_name."</td>"; } echo "</tr>"; while($res = mysql_fetch_array($struct)){ echo "<tr>"; for($i=0; $i<$field_count; ++$i){ echo "<td>".$res[$i]."</td>"; } echo "</tr>"; } echo "</table>"; } ?>
<?php $db = $_GET[‘db‘]; $table = $_GET["table"]; $link = mysql_connect("localhost","root","admin"); mysql_query("set names utf8"); mysql_query("use $db"); $data = mysql_query("select * from $table"); if(!$data){ echo "执行失败,请参考:".mysql_error(); } else{ echo "执行成功!数据如下:"; echo "<table border=‘1‘>"; $field_count = mysql_num_fields($data); echo "<tr>"; for($i=0; $i<$field_count; ++$i){ $field_name = mysql_field_name($data,$i); echo "<td>".$field_name."</td>"; } echo "</tr>"; while($res = mysql_fetch_array($data)){ echo "<tr>"; for($i=0; $i<$field_count; ++$i){ echo "<td>".$res[$i]."</td>"; } echo "</tr>"; } echo "</table>"; } ?>
辅导日
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。