Re: Validation of Primary Key Datetime variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just a thought... Using a primary key that is controlled by the user rather than your db system is risky, especially if the user can change the value after adding the record. Why not use an auto_increment field as your primary key and an indexed datetime column to list rows in the order you wish? 

Randy Clamons
Systems Programming
Novaspace.com


> ------------Original Message------------
> From: "S.D.Price" <S.D.Price@xxxxxxxxxx>
> To: "php-windows" <php-windows@xxxxxxxxxxxxx>
> Date: Mon, Feb-28-2005 6:18 AM
> Subject:  Validation of Primary Key Datetime variable
>
> Hi, I wonder if anyone can help.
> 
> I have designed a newsblog which uses PHP and MySQL. Each news story 
> has
> a primary key which is the current date. The datatype used in MySQL is
> "datetime". When stories are extracted from the database the user can
> then navigate based on date order. 
> 
> When a user adds a news story to the database the current days date is
> shown in the form using 
> 
> <dt>
> <label for="publish_date"><?php echo $publish_datelabel ?></label></dt>
> <dd><input type="text" name="publish_date" id="publish_date"
> value="<?php echo date('Y-m-d H:i:s') ?>"/></dd>
> 
> 
> This is the date added to the DB by default. 
> 
> However, the user must be able to change the date so that they can set 
> a
> date sometime in the future when they want the story to be published.
> The only stories shown in the archive (and pulled through to the home
> page) are those which are before or on today's date.
> 
> My problem is that I am not sure how to validate any changes made to 
> the
> $publish_date so that it will conform to the required datetime range in
> MySQL and not give the useless answer 0000:00:00 00:00:00.
> 
> Does anyone know how to do this?
> Thanks
> 
> Steven Price 
> 
> 
> 
> 
-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux