I have a query that looks like this: (I insert the date created with the php
date function)
$status = "Active";
//(I cannot use the mysql timestamp function for other reason).
$curdate = date("m/j/Y H:i");
$owner = "not assigned";
@ $db_connect = mysql_connect(" localhost", "$db_userna me", "$db_password") ;
if (!$db_connect)
{
echo "Unable to connect to the database;
exit;
}
mysql_select_db ("$db");
$query = "insert into tickets (user, status, loannum, problem, description,
multiples, ticketnumber, ip, office, submissiontime, ticketowner) values
('$user1', '$status', '$loannum', '$problem', '$description', '$multiples',
'$ticketnumber' , '$ip', '$office', '$curdate', '$owner')";
$result = mysql_query($qu ery);
I need to pull out the last fifty records from the database, so I use this
query:
$order = $order;
if ($order ==""){
$order = "user";
}
mysql_select_db ("$db");
$query = "select * from tickets ORDER by $order";
$result = mysql_query($qu ery);
$num = mysql_num_rows( $result);
if I order the tickets by submission time, it orders the items, but not
correctly. It looks like php treating the submissiontime like integer:
example:
12/1/2003 16:51
12/1/2003 16:58
12/10/2003 12:29
12/10/2003 12:36
12/11/2003 07:10
12/2/2003 09:16
How can I tell php treat the submissiontime field in mysql as a date so it
can be ordered correctly? I need to do this so I can do some maths and some
sorting on the the date.
TIA
Yulia
date function)
$status = "Active";
//(I cannot use the mysql timestamp function for other reason).
$curdate = date("m/j/Y H:i");
$owner = "not assigned";
@ $db_connect = mysql_connect(" localhost", "$db_userna me", "$db_password") ;
if (!$db_connect)
{
echo "Unable to connect to the database;
exit;
}
mysql_select_db ("$db");
$query = "insert into tickets (user, status, loannum, problem, description,
multiples, ticketnumber, ip, office, submissiontime, ticketowner) values
('$user1', '$status', '$loannum', '$problem', '$description', '$multiples',
'$ticketnumber' , '$ip', '$office', '$curdate', '$owner')";
$result = mysql_query($qu ery);
I need to pull out the last fifty records from the database, so I use this
query:
$order = $order;
if ($order ==""){
$order = "user";
}
mysql_select_db ("$db");
$query = "select * from tickets ORDER by $order";
$result = mysql_query($qu ery);
$num = mysql_num_rows( $result);
if I order the tickets by submission time, it orders the items, but not
correctly. It looks like php treating the submissiontime like integer:
example:
12/1/2003 16:51
12/1/2003 16:58
12/10/2003 12:29
12/10/2003 12:36
12/11/2003 07:10
12/2/2003 09:16
How can I tell php treat the submissiontime field in mysql as a date so it
can be ordered correctly? I need to do this so I can do some maths and some
sorting on the the date.
TIA
Yulia
Comment