mlmorg
02-20-2009, 10:51 PM
I created a blog with an admin section and my friend wants to be able to change the published date/time of a post (it had formerly just added the time depending on when he published it).
This is fine, but I NEED the time to be distinct in the database. How can I run a query that checks if the time I'm about to put in the DB is already in there and, if it is, adds 1 second to the time until I get a distinct time?
Thanks for any help!
Can it be as simple as this:
<?php
while(!isset($time_success)){
$query = "SELECT * FROM posts WHERE time = '$time'";
$result = mysql_query($query);
if(mysql_num_rows($result)){
$time = $time + 1;
} else {
$time_success = 'success';
}
}
?>
This is fine, but I NEED the time to be distinct in the database. How can I run a query that checks if the time I'm about to put in the DB is already in there and, if it is, adds 1 second to the time until I get a distinct time?
Thanks for any help!
Can it be as simple as this:
<?php
while(!isset($time_success)){
$query = "SELECT * FROM posts WHERE time = '$time'";
$result = mysql_query($query);
if(mysql_num_rows($result)){
$time = $time + 1;
} else {
$time_success = 'success';
}
}
?>