Ok, whatver you wanted is closed to completed, minus the checkbox and saving part. you can improvise, or maybe i can complete it tomorrow for you.
create a db schema :
+----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| username | varchar(300) | YES | | NULL | |
| comment | varchar(3000) | YES | | NULL | |
| time | varchar(30) | YES | | NULL | |
| date | date | YES | | NULL | |
+----------+------------------+------+-----+---------+----------------+
PHP Code:
<form id="form1" name="form1" method="post" action="">
<label>
<strong>Username</strong>:
<input type="text" name="user" id="user" />
</label>
<p><strong>Comments: </strong></p>
<p>
<label>
<textarea name="comments" id="comments" cols="45" rows="5"></textarea>
</label>
</p>
<p>
<label>
<input type="submit" name="button" id="button" value="Submit" />
</label>
</p>
</form>
<?php
include('dbconn.php');
$date = date("Y-m-d");
$time = date("g:i a");
if(isset($_POST['user'])){
$username = $_POST['user'];
}
if(isset($_POST['comments'])){
$comments = $_POST['comments'];
}
if($username != "" || $comments !=""){
//insert this value
$insert = "insert into comments(username,time,date,comment)values('$username','$time','$date','$comments');";
$suc = mysql_query($insert);
$newID = mysql_insert_id();
}
//fetch the latest 10 comments;
$fetch = "select * from comments order by date limit 10 ;";
$suc = mysql_query($fetch);
?>
<table width="100%" style='font-size:13px;'>
<?php
while($info = mysql_fetch_array($suc)){ ?>
<tr>
<td>
<?php
echo "<b>".$info['date']." | ".$info['time']."</b> ".$info['comment'];
?>
</tr>
</td>
<?php }?>
</table>
Bookmarks