gpt4 book ai didi

PHP 和 MySQL。查看主题日期

转载 作者:行者123 更新时间:2023-11-29 23:23:06 25 4
gpt4 key购买 nike

我可以根据讲师的期末考试作业创建一个网站论坛。现在我的编码出现问题。请修复。

创建主题/线程时,我们打开主题/线程nya,有一个日期告诉我们主题/线程的创建时间。但在我的编码中,显示数据库中的所有现有日期。

    <?php
session_start();
if($_SESSION['logged'] == true)
{
if(isset($_SESSION['username']))
{ echo $username=$_SESSION["username"];
}else
{
header('Location:login.php');
}
}
?>



<!DOCTYPE html>
<html>
<head>

<!==CSS>
<style>
#clock{
pointer-events: none
}
</style>
<!close css>

<img src="head1.jpg" alt="icon" width="100%" height="110">
<img src="line1.jpg" alt="icon" width="100%" height="20">
<title>Venray</title>
<body background="alienbackground.jpg">
<font face="comic sans MS">
<!==Table Login==>
<table border="0" style="width:99%" bgcolor="#424242" align="center">
<tr>
<table border="0" style="width:98%" bgcolor="#424242" align="center">
<tr>
<td> <img src="start.gif" alt="icon" width="26" height="26"> </td>
<td rowspan="2" align="right">
<table border="0" bgcolor="#2E2E2E">

<tr>
<td><b>
<?php
{
echo "<tr><td><b><font color=green> Welcome, ";
echo $username;
echo '<a href="logout.php" style="text-decoration:none; color:red;"><span>, [Log Out]</span></a></li>';
echo "</tr></td></b></font>";
}
?>

</b></td>
</tr>

<tr>
<td id=clock align="right"><b><iframe src="http://free.timeanddate.com/clock/i4eh41xm/n108/tlsg/fn7/fs12/tct/pct/ftb/tt0/tw1/tm1/th1" frameborder="0" width="182" height="20" allowTransparency="true"></iframe>
</b></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top"><b><font size="4">Community</font></b></td>
</tr>
</table>
</tr>


<p style="color:#ff0000">

<!==Table please welcome==>
<table border="0" style="width:98%" bgcolor="#424242" align="center">

<tr>
<td align="right">
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
require("conn.php");
$con = mysql_connect($server,$user,$pass);
$db = mysql_select_db($db);
$sql = "select * from d_admin order by username";
//echo $sql;
$ambil_data = mysql_query($sql);
while($data = mysql_fetch_array($ambil_data))
$result = mysql_query("SELECT * FROM d_admin");
$rows = mysql_num_rows($result);
echo "Member " . $rows . " * ";
?>
Post 1 * Topics 1 </td>
</tr>
</table>
<br>
<table border="1" width="98%" height="6%" align="center" bgcolor=#424242 >
<tr>
<td align="left" ><a href="forumuser.php"><img src="hometopic.gif" width="40" height="40"></a> </td>
</tr>


<tr>
<table border="1" width="98%" height="40" align="center" bgcolor="#86B404" bordercolor=green>
<tr>

<th width="70%" align="left"><img src="open.png" width="40" height="40">Posting Display</th>
<td align="right"><a href="replay"><img src="replay.png" width="150" height="40"></a></td>
</tr>
</tr>

<tr>

<table border="1" width="98%" height="70" align="center" bgcolor=#424242>


***<?php
error_reporting(E_ALL ^ E_DEPRECATED);
$con = mysql_connect($server,$user,$pass);
$db = mysql_select_db($db);
$sql = "select * from tabel_topik ";
$ambil_data = mysql_query($sql);
while($data = mysql_fetch_array($ambil_data))
{
echo '<tr><th align="left" valign="top" colspan="2" >'.$data['date'].'</th></tr>';
echo '</tr>';
}
?>***


<tr><th align="center" width="15%">Venray</th><td align="left" width="85%">title</td></tr>
<tr><th align="top" width="15%">join dates</th><td align="left" rowspan="2" valign="top">awd</td></tr>
<tr><th align="center" valign="top" width="15%" height="400">9 Post</th></tr>
<tr>
<td align="left">*</td>
<td align="right" width="85%"><a href=""><img src="replay.png" width="150" height="40"></a></td></tr>
</table>
</tr>
</table>
</body>
</font>
</head>
</html>

最佳答案

通过在初学者查询中传递 ID 或任何类似字段来获取论坛特定数据。然后,如果您希望格式化日期的显示方式,您可以使用 php 日期函数,如下所示:

while($data = mysql_fetch_array($ambil_data))
{
echo '<tr><th align="left" valign="top" colspan="2" >'.date('jS M, Y',strtotime($data['date'])).'</th></tr>'; //format the date as required
echo '</tr>';
}

关于PHP 和 MySQL。查看主题日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27162736/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com