嗨所以我用下面遇到了一些麻煩:如何通過最高日在PHP
for ($i = 0; $i < count($noncompUsername); $i++)
{
$tsql ="SELECT firstname,lastname,email,phone,statuschangedate FROM csvdata WHERE username = :username ORDER BY statuschangedate";
$tgetmeminfo=$DBH->prepare($tsql);
$tgetmeminfo->execute(array(':username' => $noncompUsername[$i]));
while ($trow = $tgetmeminfo->fetch(PDO::FETCH_ASSOC)){
$csvFirst = $trow['firstname'];
$csvLast = $trow['lastname'];
$csvEmail = $trow['email'];
$csvPhone = $trow['phone'];
$csvDate = $trow['statuschangedate'];
$timediff = strtotime($date) - strtotime($csvDate);
$timediff = floor($timediff/86400);
$sql ="SELECT MailingAdrs FROM insuranceverificationdisclaimer WHERE TraineeUsername = :tusername";
$getmeminfo=$DBH->prepare($sql);
$getmeminfo->execute(array(':tusername' => $noncompUsername[$i]));
while ($row = $getmeminfo->fetch(PDO::FETCH_ASSOC)){
$csvAddrs = $row['MailingAdrs'];
$change = 1;
}
if($change != 1)
{
$csvAddrs = "No address";
}
$change = 0;
echo "$timediff, $csvFirst $csvLast, $csvEmail, $csvPhone, $csvAddrs";
}
echo "
<br>
";
}
現在這個工作,但我想指出的部分是$tsql ="SELECT firstname,lastname,email,phone,statuschangedate FROM csvdata WHERE username = :username ORDER BY statuschangedate";
- 現在,當我做到這一點並且將statuschangedate的整數取爲當前日期並以整數形式打印出來,但不會根據日期進行正確排序。
所以我需要得到這個由最早的日期下令在上面,如下...
謝謝!按照從大到小的順序日期(使用DESC
)
大衛
如果你想要最古老的,你的查詢似乎就是這樣做的。 –
但是,當我把日期轉換爲整數時,它會告訴我,否則 –
所以我們可以說狀態更改日期是從上週開始的,所以它會檢查從上週到現在的日期並將其轉換爲7的整數,所以我將7中的108天以上,只是全部結束 –