php数据库
问一下怎么建立数据库呢?登陆时已经可以完成的了,就是留言功能不能实现

<code> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>留言板</title></head><div> <a href='denglu.php'>返回</a></div><?phperror_reporting(E_ALL &~ E_NOTICE);session_start(); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } else echo"<br>connected!<br>"; $selected = mysql_select_db("center" ) ;//if($selected)//echo"selected!<br>";mysql_query("set names 'utf8'");$insert_account = $_SESSION['account'];$insert_pwd = $_SESSION['password'];echo $insert_account;//echo $_POST[comment];if($_SESSION['check'] ==1){if(!empty($_POST[comment]) ){$sql="INSERT INTO comment (account,comment,time)VALUES('$insert_account','$_POST[comment]','$printtime')"; mysql_query($sql) or die(mysql_error());$_SESSION['check'] = 0;}else echo '<div align="center"><font color = "red" font size = 50>欢迎来到留言板</font>' ;}$insert_account?><div align="center"><form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"><div valign="center">请留言 </div> <textarea name="comment" rows="5" cols="40" ><?php //echo readfile("webdictionary.txt");?></textarea><tr><input type="submit" name="submit" value="提交" /></tr><p>您已提交的留言:</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/1655">
<img src="https://img.php.cn/upload/ai_manual/000/969/633/68b6d69663ee2218.png" alt="有道小P">
</a>
<div class="aritcle_card_info">
<a href="/ai/1655">有道小P</a>
<p>有道小P,新一代AI全科学习助手,在学习中遇到任何问题都可以问我。</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="有道小P">
<span>64</span>
</div>
</div>
<a href="/ai/1655" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="有道小P">
</a>
</div>
<hr><?php $pagesize=10;mysql_select_db("center") or die("no");//取得记录总数$rs,计算总页数用$rs=mysql_query("select count(*) from comment");$myrow = mysql_fetch_array($rs);$numrows=$myrow[0];echo "总留言数量:".$numrows;//计算总页数$pages=intval($numrows/$pagesize);if ($numrows%$pagesize)$pages++;//设置页数if (isset($_GET['page'])){$page=intval($_GET['page']);}else{//设置为第一页 $page=1;}//计算记录偏移量$offset=$pagesize*($page - 1);//读取指定记录数$rs=mysql_query("select * from comment order by ID desc limit $offset,10");//$offset,if ($myrow = mysql_fetch_array($rs)){ $i=0;?><table border="0" width="100%"><tr><td width="50%" bgcolor="#E0E0E0"> <p align="center">留言</td><td width="20%" bgcolor="#E0E0E0"> <p align="center">发布时间</td><td width="20%" bgcolor="#E0E0E0"> <p >留言用户</td> </tr> <?php do { $i++; ?> <tr> <td width="50%"><?php echo $myrow["comment"] ?></td> <td width="20%"><?php echo $myrow["time"] ?></td> <td width="20%"><?php echo $myrow["account"] ?></td> </tr> <?php } while ($myrow = mysql_fetch_array($rs)); echo "</table>"; } echo "<div align='center'>共有".$pages."页(".$page."/".$pages.")"; for ($i=1;$i< $page;$i++) echo "<a href='comment.php?page=".$i."'>[".$i ."]</a> "; echo "[".$page."]"; for ($i=$page+1;$i<=$pages;$i++) echo "<a href='comment.php?page=".$i."'>[".$i ."]</a> "; echo "</div>"; ?><br><br><br></body> <!-- <script src="/javascript/myScript.js" charset="utf-8"> </script> --></html></code>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号