简单的网站代码(求救!写简单,单页网站代码!!!)

本文目录
求救!写简单,单页网站代码!!!
《script language="javascript"》
《!--
//var Wind;
function newWindow(url,height,width)
{
Wind=window.open(url,"","width="+width+",height="+height);
}
function closeWind()
{
if(Wind)
{
Wind.close();
Wind=null;
}
}
var WindControl=setTimeout("closeWind()",70000);
《/script》
《script language="javascript"》newWindow("http://www.baidu.com",900,900)《/script》
最后一行代码,复制 再粘贴,就可以增加弹出数量900.900是页面大小自己设
想学习网站对接数据库的谁能给个简单的代码 网页就上两个输入框,一个提交按钮,一个查询按钮
使用PHP和MySQL实现。
HTML代码:php code
《!DOCTYPE html》
《html》
《head》
《title》网站对接数据库示例《/title》
《/head》
《body》
《h1》网站对接数据库示例《/h1》
《form method="post" action="submit.php"》
《label for="input"》输入框:《/label》
《input type="text" name="input" id="input" required》
《input type="submit" value="提交"》
《/form》
《form method="post" action="query.php"》
《label for="query"》查询:《/label》
《input type="text" name="query" id="query" required》
《input type="submit" value="查询"》
《/form》
《/body》
《/html》
submit.php代码:php code
《?php
// 连接数据库
$db_host = "localhost"; // 数据库服务器地址
$db_user = "root"; // 数据库用户名
$db_pwd = ""; // 数据库密码
$db_name = "test"; // 数据库名
$conn = mysqli_connect($db_host, $db_user, $db_pwd, $db_name);
// 获取输入框内容
$input = $_POST;
// 将输入框内容插入数据库
$sql = "INSERT INTO input (content) VALUES (’$input’)";
mysqli_query($conn, $sql);
// 关闭数据库连接
mysqli_close($conn);
echo "提交成功!";
?》
query.php代码:php code
《?php
// 连接数据库
$db_host = "localhost"; // 数据库服务器地址
$db_user = "root"; // 数据库用户名
$db_pwd = ""; // 数据库密码
$db_name = "test"; // 数据库名
$conn = mysqli_connect($db_host, $db_user, $db_pwd, $db_name);
// 获取查询框内容
$query = $_POST;
// 查询数据库
$sql = "SELECT * FROM input WHERE content LIKE ’%$query%’";
$result = mysqli_query($conn, $sql);
// 输出查询结果
while ($row = mysqli_fetch_assoc($result)) {
echo $row . "《br》";
}
// 关闭数据库连接
mysqli_close($conn);
?》
以上代码实现了一个简单的网站对接数据库的功能,用户可以在输入框中输入文字并提交,程序将输入框内容保存到数据库中。用户也可以在查询框中输入关键字并提交,程序将查询数据中匹配的内容并输出。

更多文章:
中国建设银行手机银行app(中国建设银行app怎么免密登录)
2026年11月3日 18:30








