求一个可以读取,修改,保存文本文件的ASP源码。
发布网友
发布时间:2024-10-15 12:33
我来回答
共1个回答
热心网友
时间:2024-11-14 07:30
这么简单,我有PHP的,你要吗?
<?php
function datebaselink($name,$password)//登录方法
{
$conn = datebase_start();
$user_name = $name;//帐号
$user_password = $password;//密码
$sql = "select * from test_account where name = '$user_name' and password = '$user_password'";
$result = mysql_query($sql);//执行SQL语句
$num_row = mysql_num_rows($result);//返回是否有相同帐号的行
mysql_close($conn);
return $num_row;
}
function datebase_start()//打开数据库方法
{
$db_name = "root";//数据库帐号
$db_password = "000000";//数据库密码
$db_test = "test";//数据库名称
$conn = mysql_connect("localhost",$db_name,$db_password);//连接数据库
mysql_select_db($db_test,$conn);//选择数据库
return $conn;
}
function datebase_list()//显示数据库表test_account_list所有数据
{
$conn = datebase_start();
$sql = "select * from test_account_list";
mysql_query("set names 'utf8'");//转换成UTF8格式
$query = mysql_query($sql);
while($result = mysql_fetch_array($query,MYSQL_ASSOC))
{
echo "<tr><td>".$result['id']."</td>";
echo "<td>".$result['class']."</td>";
echo "<td>".$result['name']."</td>";
echo "<td>".$result['tel']."</td>";
echo "<td>".$result['title']."</td>";
echo "<td>".$result['connet']."</td>";
echo "<td>".$result['time']."</td>";
echo "<td><input type = 'button' //button 的左右需要用单引号
name = $result[id]
value = 'delete'
onclick = \"javascript:window.location = 'Reveal_list.php?id=".$result['id']."'\">
</td>"; //注意...'""'.重要
echo "<td><a href = 'Modification.php?id=".$result['id']."' >modification</a>
</td></tr>";
}
mysql_close($conn);
return $result;
}
function datebase_delete($id)//删除某行数据
{
$delete_id = $id;
$conn = datebase_start();
$sql = "delete from test_account_list where id = '$delete_id'";
$result = mysql_query($sql);
if($result == true)
{
echo "yes";
// header("REFRESH:1;URL='Reveal.php'");
}else
{
echo "no";
header("REFRESH:1;URL='Reveal.php'");
}
}
function datebase_select_onerow($id)//查询某一行的数据.
{
$select_id = $id;
$conn = datebase_start();
$sql = "select * from test_account_list where id = '$select_id'";
$result = mysql_query($sql);
$row_one = mysql_fetch_array($result,MYSQL_ASSOC);
return $row_one;
}
function datebase_update($id,$class,$name,$tel,$title,$connet,$time)//更新数据库
{
$UP_id = $id;
$UP_class = $class;
$UP_name = $name;
$UP_tel = $tel;
$UP_title = $title;
$UP_connet = $connet;
$UP_time = $time;
$conn = datebase_start();
$sql = "update test_account_list set class = '$UP_class',name = '$UP_name',tel = '$UP_tel',title = '$UP_title',connet = '$UP_connet',time = '$UP_time' where id = '$UP_id'";
mysql_query("set names 'utf8'");
$result = mysql_query($sql);
return $result;
}
function datebase_insert($class,$class,$name,$tel,$title,$connet,$time)
{
$IS_class = $class;
$IS_name = $name;
$IS_tel = $tel;
$IS_title = $title;
$IS_connet = $connet;
$IS_time = $time;
$conn = datebase_start();
$sql = "insert into test_account_list(id,class,name,tel,title,connet,time)value(NULL,'$IS_class','$IS_name','$IS_tel','$IS_title','$IS_connet','$IS_time')";
echo $sql;
//$result = mysql_query($sql);
}
?>