Well I've got a task to keep "quotes" right into a database (Already carried this out) and display them &lifier sort them out which are more recent quotes. I am presuming to obtain the "newestInch, I'd have to store date/duration of the posted quote.

I'm a new comer to PHP and learning, so I'm not sure how you can exactly do that.

This is actually the PHP for adding the quotes towards the database. You will find two posts within the table known as "quotes" and "id". I am speculating I must also create a column for that date too?

require('includes/connect.php');


    $quote = $_POST['quote'];
    $quotes = mysql_real_escape_string($quote);


    mysql_query("INSERT INTO entries (quote) VALUES('$quotes')")
    or die(mysql_error());

Wouldso would I additionally place the date?

use CURDATE() if you wish to place the current date

example:

$query_auto = "INSERT INTO tablename (col_name, col_date) VALUE ('DATE: Auto CURDATE()', CURDATE() )";

but when you wqant it by hand then should make use of this:

$query_manual = "INSERT INTO tablename (col_name, col_date) VALUES ('DATE: Manual Date', '2008-07-04')";

UPDATE

CREATE TABLE auto_ins
    (
        `MySQL_Function` VARCHAR(30),
        `DateTime` DATETIME,
        `Date` DATE,
        `Time` TIME,
        `Year` YEAR,
        `TimeStamp` TIMESTAMP
    );

INSERT INTO auto_ins
    (`MySQL_Function`, `DateTime`, `Date`, `Time`, `Year`, `TimeStamp`)
VALUES
    (“CURDATE()”, CURDATE(), CURDATE(), CURDATE(), CURDATE(), CURDATE());

SCREEN SHOT

Should you only want the newest quotes, you can just sort your result set by their id DESC presuming the id is definitely an auto-incremented value.

Yes, you'll need a third column allows say most_recent (understood to be date or datetime) :

mysql_query("INSERT INTO entries (quote, most_recent) VALUES('$quotes', now())")

You'll need a minimum of handful of tables who posted the quote and also the quote table itself.

create table users(id int primary key not null, username varchar(32),pwd varchar(32));

you can include any info to that particular table like current email address and so forth.

create table quotes (
id int not null , 
user_id integer,
quote_text varchar(256),
inserted_date timestamp default current_timestamp ,primary key (id));
alter table quotes add constraint fk_users foreign key(user_id) references users(id);

Otherwise you can modify them. It isn't about php here its about DB design generally.

Make use of this code:

require('includes/connect.php');


$quote = $_POST['quote'];
$quotes = now().' - '.mysql_real_escape_string($quote);
// THIS WILL ADD THE DATE AND TIME TO YOUR $quotes STRING.


mysql_query("INSERT INTO entries (quote) VALUES('$quotes')")
or die(mysql_error());