想要从phpmyadmin回显和编辑表数据

时间:2015-05-06 04:10:07

标签: php mysql phpmyadmin

我有这个代码可以回显所有表数据。但是如果我想从html页面编辑那些数据那么我需要做些什么改变呢?

<?php

    // list all the table in database
    $result = mysql_query("show tables");

    // show all the field with type, lenght,description of a specific table
    $result = mysql_query("DESCRIBE pub_log");

    // show a specific tables row 
    $result = mysql_query("SELECT * FROM pub_log");

    if (mysql_num_rows($result)>0){
        $r = mysql_fetch_array($result,MYSQL_ASSOC);
        $table="<table><tr>";
        $firstLine="<tr>";

            foreach ($r as $k => $v){
                $table .="<td>".$k."</td>";
                $firstLine .="<td>".$v."</td>";
            }

            $table.="</tr>".$firstLine."</tr>";

            while($r = mysql_fetch_array($result,MYSQL_ASSOC)){
                $table.="<tr>";

                foreach($r as $k => $v)
                    $table.="<td>".$v."</td>";
                    $table.="</tr>";
                }

                $table .="</table>";
                echo $table;
            }
    }
?>

0 个答案:

没有答案