PHP语言之一个对数据库进行操作的程序
小标 2018-09-14 来源 : 阅读 518 评论 0

摘要:本文主要向大家介绍了PHP语言之一个对数据库进行操作的程序,通过具体的内容向大家展示,希望对大家学习php语言有所帮助。

本文主要向大家介绍了PHP语言之一个对数据库进行操作的程序,通过具体的内容向大家展示,希望对大家学习php语言有所帮助。

''  db.func:


function GetRows( $Database, $Query ) {
mysql_connect ("ftp", "root", "");
$db = mysql_select_db( $Database );
if ( ! $db ) {
echo "无法连结数据库!";
exit;
}

$rows = mysql_query( $Query );
if ( ! $rows ) {
echo "SQL指令错误!";
exit;
}
return $rows;
}

function ConnectDatabase( $Database ) {
mysql_connect ("ftp", "root", "");
$db = mysql_select_db( $Database );
if ( ! $db ) {
echo "无法连结数据库!";
exit;
}
}
?>

cratetable.php:


function CreateTable() {
$link = mysql_connect ("ftp", "root", "");
$db = mysql_select_db("pcadmin");
if ( ! $db ) {
echo "连接到数据库失败!";
exit;
}
$rows = mysql_query("select * from Profile");
if ( ! $rows ) {
$sql = "Create Table Profile (ID integer auto_increment primary key,Name char(255),Produce char(255),Lianluo char(255),Tel integer(15),Email char(255))";
mysql_query($sql);
}

$rows = mysql_query("select * from Aplication");
if ( ! $rows ) {
$sql = "Create Table Aplication(Name char(255) primary key,IP char(255),Ap char(255),Directory char(255))";
mysql_query($sql);
}
mysql_close ($link);
}
CreateTable();
?>

input.htm:




    </div>

    <div class="article_ab" style="width: 720px;height: 100px;margin: 0 auto;margin-top: 15px;">

    </div>

    <div class="article_cmnt">
        <div class="cmnt_title">吐了个 "CAO" !</div>
        <form action="" method="post">
            <div class="cmnt_text">
                <textarea class="ping-txt" onfocus="ck_txt(this);" onblur="ck_txt2(this);" id="ping-txt" name="ping-txt" >吐个槽吧,看都看了</textarea>
            </div>
            <div class="cmnt_cmt">
                <div class="cmnt_login_box">
                                        <a href="https://www.php1.cn/?s=user/login/index&from=https%3A%2F%2Fwww.php1.cn%2Fdetail%2Fphp-9a9bafce85.html">会员登录</a> | <a href="//www.php1.cn/?s=user/reg/index">用户注册</a>
                                    </div>
                <div class="post_cmnt"><input type="button" value="吐  槽" onclick="post_ping();" /></div>
            </div>
        </form>

        
    </div>
</div>

<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushBash.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushCSharp.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushCss.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushDelphi.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushDiff.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushGroovy.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushJava.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushPhp.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushPlain.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushPython.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushRuby.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushScala.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushSql.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushVb.js"></script>
<script type="text/javascript" src="https://www.php1.cn/SyntaxHighlighter/scripts/shBrushXml.js"></script>
<link type="text/css" rel="stylesheet" href="https://www.php1.cn/SyntaxHighlighter/styles/shCore.css"/>
<link type="text/css" rel="stylesheet" href="https://www.php1.cn/SyntaxHighlighter/styles/shThemeLiuQing.css"/>
<style>.syntaxhighlighter{padding-top:20px;padding-bottom:20px;}</style>
<script type="text/javascript">
    SyntaxHighlighter.config.clipboardSwf = 'https://www.php1.cn/SyntaxHighlighter/scripts/clipboard.swf';
    SyntaxHighlighter.all();
</script>    <div class="article_right">

    <div class="profile">
        <div class="login">
    <!-- 未登录 -->
    <div class="login-info">
        <div class="user-photo">
            <img src="/style/home/images/user-no-photo.jpg" class="lazy-img" data-url="" alt="第一PHP社区">
        </div>
        <div class="user-txt">
            <p style="color: #666;font-weight: bold;">Hi,亲爱的小伙伴!</p>

            <p>欢迎来到php1.cn社区!</p>
            <p><a href="https://www.php1.cn/?s=user/login/index&from=https%3A%2F%2Fwww.php1.cn%2Fdetail%2Fphp-9a9bafce85.html" class="login-open" title="PHP登录">点击登录, 发现精彩</a></p>
        </div>
    </div>
    <div class="login-btn">
        <a href="https://www.php1.cn/?s=user/reg/index" class="skins-btn sign-btn" title="PHP用户注册">注册</a>
        <a href="https://www.php1.cn/?s=user/login/index&from=https%3A%2F%2Fwww.php1.cn%2Fdetail%2Fphp-9a9bafce85.html" class="skins-btn skins-btn-green">登录</a>
    </div>
</div>
    </div>

    <div class="tools">
        <div class="tools_top_line">
            <div class="tools_t_l"></div>
            <div class="tools_t_r"></div>
        </div>
        <div class="tools_top">Tools Online | 在线开发工具</div>
        <div class="tools_box">
            <ul>
                                <li>
                    <a href="https://tools.php1.cn/?s=jsformat" title="HTML/JS格式化/压缩">HTML/JS格式化/压缩</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=cssformat" title="CSS代码格式化工具">CSS代码格式化工具</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=editor" title="文章自动排版工具">文章自动排版工具</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=htmljs" title="HTML/JS转换">HTML/JS转换</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=utf8" title="UTF-8编码转换工具">UTF-8编码转换工具</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=unicode" title="Unicode 转换">Unicode 转换</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=urlencode" title="URL编码解码">URL编码解码</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=qrcode" title="二维码生成工具">二维码生成工具</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=ip" title="IP地址查询">IP地址查询</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=httpcode" title="HTTP状态码(响应码)">HTTP状态码(响应码)</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=headers" title="网页Header头">网页Header头</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=htmlcode" title="网页源代码">网页源代码</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=colorjson" title="JSON解析着色">JSON解析着色</a>
                </li>
                                <li>
                    <a href="https://tools.php1.cn/?s=diff" title="Diff文件比较">Diff文件比较</a>
                </li>
                            </ul>
        </div>
    </div>




    <div class="rank">
        <div class="rank_top_line">
            <div class="rank_t_l"></div>
            <div class="rank_t_r"></div>
        </div>
        <div class="rank_top">RankList | 热门文章</div>
        <div class="rank_box">
            <ul>
                                <li>
                    <b >1</b><a href="//www.php1.cn/detail/php-be64d92170.html" title="Python中的hypot()方法使用简介">Python中的hypot()方法使用简介</a>
                </li>
                                <li>
                    <b >2</b><a href="//www.php1.cn/detail/php-e5a39edeeb.html" title="python绘图方法实例入门">python绘图方法实例入门</a>
                </li>
                                <li>
                    <b >3</b><a href="//www.php1.cn/detail/php-73e0e02cc5.html" title="用Python操作字符串之rindex()方法的使用">用Python操作字符串之rindex()方法的使用</a>
                </li>
                                <li>
                    <b >4</b><a href="//www.php1.cn/detail/php-98060ae33f.html" title="python文件操作之目录遍历实例分析">python文件操作之目录遍历实例分析</a>
                </li>
                                <li>
                    <b >5</b><a href="//www.php1.cn/detail/php-bb189c2240.html" title="python对数组进行反转的方法">python对数组进行反转的方法</a>
                </li>
                                <li>
                    <b class="black">6</b><a href="//www.php1.cn/detail/php-d2e2b308f9.html" title="在Python中使用sort()方法进行排序的简单教程">在Python中使用sort()方法进行排序的简单教程</a>
                </li>
                                <li>
                    <b class="black">7</b><a href="//www.php1.cn/detail/php-afe96724c2.html" title="在Python的列表中利用remove()方法删除元素的教程">在Python的列表中利用remove()方法删除元素的教程</a>
                </li>
                                <li>
                    <b class="black">8</b><a href="//www.php1.cn/detail/php-331eee1d62.html" title="Python批量重命名同一文件夹下文件的方法">Python批量重命名同一文件夹下文件的方法</a>
                </li>
                                <li>
                    <b class="black">9</b><a href="//www.php1.cn/detail/php-e527f06c44.html" title="Python中类型关系和继承关系实例详解">Python中类型关系和继承关系实例详解</a>
                </li>
                                <li>
                    <b class="black">10</b><a href="//www.php1.cn/detail/php-d72969ff82.html" title="Python实现二分查找算法实例">Python实现二分查找算法实例</a>
                </li>
                                <li>
                    <b class="black">11</b><a href="//www.php1.cn/detail/php-6605d0ee4d.html" title="Python socket编程实例详解">Python socket编程实例详解</a>
                </li>
                                <li>
                    <b class="black">12</b><a href="//www.php1.cn/detail/php-5cbb43c50f.html" title="Python下载懒人图库JavaScript特效">Python下载懒人图库JavaScript特效</a>
                </li>
                            </ul>
        </div>
    </div>

    <div class="wx_pic">
        <div class="wx_top_line">
            <div class="wx_t_l"></div>
            <div class="wx_t_r"></div>
        </div>
        <div class="wx_top">扫码关注 PHP1 官方微信号</div>
        <div class="wx_box">
            <img src="/style/home/images/wx_pic.png"/>
        </div>
    </div>

    
    <div class="baidu_ad_box" style="width: 320px;height: 280px;margin-top: 15px;text-align: center;border: 1px solid #ddd;padding-top: 10px;padding-bottom: 10px;">
        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
        <!-- zishiying -->
        <ins class="adsbygoogle"
             style="display:block"
             data-ad-client="ca-pub-8923551941185667"
             data-ad-slot="9743942645"
             data-ad-format="auto"></ins>
        <script>
            (adsbygoogle = window.adsbygoogle || []).push({});
        </script>
    </div>

    <div class="rank">
        <div class="rank_top_line">
            <div class="rank_t_l"></div>
            <div class="rank_t_r"></div>
        </div>
        <div class="rank_top">Recommend | 推荐阅读</div>
        <div class="rank_box">
            <ul>
                                <li>
                    <b >1</b><a href="//www.php1.cn/detail/php-8dd9ccef52.html" title="Oracle 11g RHEL 6.3 装缺少pdksh-5.2.14-1.i386.rpm">Oracle 11g RHEL 6.3 装缺少pdksh-5.2.14-1.i386.rpm</a>
                </li>
                                <li>
                    <b >2</b><a href="//www.php1.cn/detail/php-9feff32956.html" title="InnoDB存储引擎的启动、关闭与恢复">InnoDB存储引擎的启动、关闭与恢复</a>
                </li>
                                <li>
                    <b >3</b><a href="//www.php1.cn/detail/php-b802fb8f02.html" title="MySQL自带的性能压力测试工具mysqlslap详解">MySQL自带的性能压力测试工具mysqlslap详解</a>
                </li>
                                <li>
                    <b >4</b><a href="//www.php1.cn/detail/php-1e546c0700.html" title="通过expdpimpdp把11g的数据迁移到10g平台的要点">通过expdpimpdp把11g的数据迁移到10g平台的要点</a>
                </li>
                                <li>
                    <b >5</b><a href="//www.php1.cn/detail/php-864bc425bb.html" title="分析MySQL慢查询日志的好工具--mysqlsla">分析MySQL慢查询日志的好工具--mysqlsla</a>
                </li>
                                <li>
                    <b class="black">6</b><a href="//www.php1.cn/detail/php-6a84d006bf.html" title="实例宕机引发的ORA-00240错误">实例宕机引发的ORA-00240错误</a>
                </li>
                                <li>
                    <b class="black">7</b><a href="//www.php1.cn/detail/php-2aa78f9ab6.html" title="AIX上安装Oracle 10201">AIX上安装Oracle 10201</a>
                </li>
                                <li>
                    <b class="black">8</b><a href="//www.php1.cn/detail/php-f3a3b71e23.html" title="Oracle技术之大量会话出现resmgr:become active等待">Oracle技术之大量会话出现resmgr:become active等待</a>
                </li>
                                <li>
                    <b class="black">9</b><a href="//www.php1.cn/detail/php-26fbca5f12.html" title="ORA-00600: internal error code, arguments: [ktrgcm_3]">ORA-00600: internal error code, arguments: [ktrgcm_3]</a>
                </li>
                                <li>
                    <b class="black">10</b><a href="//www.php1.cn/detail/php-13c0efcf72.html" title="Oracle Data Guard 的角色转换">Oracle Data Guard 的角色转换</a>
                </li>
                                <li>
                    <b class="black">11</b><a href="//www.php1.cn/detail/php-70fa78ec2d.html" title="00600 [2662]错误解决">00600 [2662]错误解决</a>
                </li>
                                <li>
                    <b class="black">12</b><a href="//www.php1.cn/detail/php-8a8b6b06fd.html" title="Oracle安装后忘记用户名或密码+创建新登陆用户">Oracle安装后忘记用户名或密码+创建新登陆用户</a>
                </li>
                            </ul>
        </div>
    </div>





</div>    <div style="clear: both;"></div>
</div>



<div style="clear: both"></div>
<div class="bottom">
    PHP1.CN | 中国最专业的PHP中文社区 | <a href="https://news.php1.cn/" title="PHP资讯">PHP资讯</a> | <a href="https://school.php1.cn/" title="PHP教程">PHP教程</a> | <a href="https://database.php1.cn/" title="数据库技术">数据库技术</a> | <a href="https://server.php1.cn/" title="服务器技术">服务器技术</a> | <a href="https://web.php1.cn/" title="前端技术">前端开发技术</a> | <a href="https://www.php1.cn/phpframework.html" title="PHP框架">PHP框架</a> | <a href="https://tools.php1.cn/">开发工具</a>  | <a href="https://ask.php1.cn/" title="PHP问答">PHP问答</a><BR />
    Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved  PHP1.CN 第一PHP社区  版权所有 <BR />
          
</div>
<script>
    (function(){
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        }
        else {
            bp.src = 'https://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script></body>
</html>    

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标编程语言PHP频道!

本文由 @小标 发布于职坐标。未经许可,禁止转载。
喜欢 | 1 不喜欢 | 0
看完这篇文章有何感觉?已经有1人表态,100%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程