dsf1222 2012-06-04 12:09
浏览 100
已采纳

如果最大时间戳大于其他最大时间戳

I'm still struggling making a menu with six links with images that differs depending on if a new record has ben added or not. I made a table which records the users clicks and the corresponding link_url and timestamp. I then want to compare the timestamp in the latest record in matningar containing the username and the matningstyp.

$query="SELECT max(click_timestamp) AS maxts FROM clicks WHERE username='$session->username' AND link_url='http://xxx/admin/amfmci.php'";
$result=mysql_query($query) or die(mysql_error());
$line = mysql_fetch_assoc($result);

$query1="SELECT max(datum) AS maxts FROM matningar WHERE kontakt='$session->username' AND matningstyp='bbb'";
$result1=mysql_query($query1) or die(mysql_error());
$line1 = mysql_fetch_assoc($result1);

$senasteclick = $line['maxts'];
$senastematning = $line1['maxts'];

if ('$senasteclick' > '$senastematning'){
echo "<a href=\"http://xxx/admin/amf.php\"><img src=\"http://xxx/admin/images/emoikon3.png\" alt=\"Digg\" width=\"64\" height=\"63\"     border=\"0\"/></a>";  }
else {
echo "fail";
}

This does not work the way I want to. If I change the if statement to less than, the image changes.

If I change the date of record itself it does not change the image... So the code does not what I want it to do :(

Anyone got any ideas?

  • 写回答

1条回答 默认 最新

  • douying9296 2012-06-04 12:25
    关注
    $query="
        SELECT max(c.click_timestamp) > max(m.datum) AS senas
        FROM clicks c
        inner join matningar m on c.username = m.kontakt
        WHERE 
            c.link_url='http://xxx/admin/amfmci.php'
            and
            m.matningstyp = 'bbb'
            and
            c.username = {$session->username}
    ";
    $result=mysql_query($query) or die(mysql_error());
    $line = mysql_fetch_assoc($result);
    $senas = $line['senas'];
    if ($senas){
    echo "<a href=\"http://xxx/admin/amf.php\"><img src=\"http://xxx/admin/images/emoikon3.png\" alt=\"Digg\" width=\"64\" height=\"63\"     border=\"0\"/></a>";  }
    else {
    echo "fail";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办