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">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<form method="post">

        <td><input type="text" name="title" /></td>
        <td><input type="text" name="author" /></td>
        <td><input type="text" name="name" /></td>
        <td><input type="text" name="copy" /></td>
        <td><input type="submit" name="submit" value="add" /></td>

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',)"); 


<table border="1">
    <th>publisher name</th>
    <th>copyright year</th>

            $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>";




Recommended Answers

All 5 Replies

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, learning, and sharing knowledge.