hai everyone! now add a product details is successfully in my table.and add,update,delete is also worked successfully.suppose i want to see product details added for which date and time.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Books</title>
</head>

<body>
<form method="post">
<table>

    <tr>
        <td>title:</td>
        <td><input type="text" name="title" /></td>
    </tr>
    <tr>
        <td>author</td>
        <td><input type="text" name="author" /></td>
    </tr>
    <tr>
        <td>publishername</td>
        <td><input type="text" name="name" /></td>
    </tr>
    <tr>
        <td>copyrightyear</td>
        <td><input type="text" name="copy" /></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td><input type="submit" name="submit" value="add" /></td>
    </tr>
</table>

<?php
if (isset($_REQUEST['submit']))
    {      
    include 'db.php';

                    $title=$_POST['title'] ;
                    $author= $_POST['author'] ;                 
                    $name=$_POST['name'] ;
                    $copy=$_POST['copy'] ;


         mysql_query("INSERT INTO `book`(title,author,publishername,copyrightyear) 
         VALUES ('$title','$author','$name','$copy',)"); 


            }
?>
</form>

<table border="1">
    <tr>
    <th>id</th>
    <th>title</th>
    <th>author</th>
    <th>publisher name</th>
    <th>copyright year</th>
    <th>action</th>
    </tr>
            <?php
            include("db.php");


            $result=mysql_query("SELECT * FROM book");
            while($test = mysql_fetch_array($result))
            {
                $id = $test['bookid'];  
                echo "<tr align='center'>";  

                echo"<td><font color='black'>" .$test['bookid']."</font></td>";
                echo"<td><font color='black'>" .$test['title']."</font></td>";
                echo"<td><font color='black'>". $test['author']. "</font></td>";
                echo"<td><font color='black'>". $test['publishername']. "</font></td>";
                echo"<td><font color='black'>". $test['copyrightyear']. "</font></td>"; 
                echo"<td> <a href ='view.php?bookid=$id'>Edit</a>";
                echo"<td> <a href ='del.php?bookid=$id'><center>Delete</center></a>";

                echo "</tr>";

            }
            mysql_close($conn);
            ?>

</table>

</body>
</html>

Add a datetime column to your table, and set it's default value to NOW().

You should in your table "book" will add new field type "timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP". And when you will update value this field was to change

add the field for date and type is timestamp.how to include the script in date function

if you are to create a date field to add an attribute "ON UPDATE CURRENT_TIMESTAMP", that value a field will be change at update.

if not.

mysql_query("INSERT INTO `book`(title,author,publishername,copyrightyear,date) 
         VALUES ('$title','$author','$name','$copy',NOW())"); 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.