prepare("SELECT punches.id as punchid, users.id as user, punchtypes.punchname as type, punches.time as time, punches.notes as notes, punches.modified as modified FROM punches INNER JOIN users ON punches.userid = users.id INNER JOIN punchtypes ON punches.punchtypeid = punchtypes.id WHERE users.id = $userid ORDER BY punches.id DESC LIMIT 1"); $result->execute(); $last = $result->fetchObject(); echo "You have been punched $last->type since $last->time."; // eventually i will get these in one query - for now this is separate to show all punches vs the last punch and status $result = $sql->prepare("SELECT punches.id as punchid, users.id as user, punchtypes.punchname as type, punches.time as time, punches.notes as notes, punches.modified as modified FROM punches INNER JOIN users ON punches.userid = users.id INNER JOIN punchtypes ON punches.punchtypeid = punchtypes.id WHERE users.id = $userid ORDER BY punches.id DESC"); $result->execute(); echo '
Time | '; echo 'Type | '; echo 'Changed | '; echo 'Notes | '; echo '
---|---|---|---|
$time | "; echo "$type | "; echo "$chg | "; echo "$notes | "; echo "