Jump to content

Recommended Posts

Hey guys im making a script for a school and i need to check the database for non validated absences in the last 48hours?

 

 

would it be something like

 

SELECT *

  FROM YOUR_TABLE t

WHERE t.datetime_column < DATE_SUB(NOW(), INTERVAL 48 HOUR)

 

how do i add in colum validated if it says no?(yes when validated)

Link to comment
https://forums.phpfreaks.com/topic/248303-check-non-validated-in-49h-span/
Share on other sites

Sorry..

 

So every time a student calls in sick they put it in the filling and it needs to be valid whiten the 48h fallowing the log..

 

So basicly i set up a script for al students.then i have a table called sick

 

ID-student id-date called-valid.

 

so buy default the valide is no when it is validated they press validated.so it goes to yes.

 

 

By two different DB for sure, do you mean two separate tables?

 

Something like this should do:

 

Student ( StudentID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), ... )
StudentSick ( StudentID INT, SickDay DATETIME, IsValidated BOOL )

 

SELECT s.FirstName, s.LastName, CASE ss.IsValidated WHEN 1 THEN 'Yes' ELSE 'No' END AS Validated
FROM Student s
JOIN StudentSick ss ON s.StudentID = ss.StudentID
WHERE ss.SickDay >= DATE_SUB(NOW(), INTERVAL 48 HOUR)

 

~juddster

By two different DB for sure, do you mean two separate tables?

 

Something like this should do:

 

Student ( StudentID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), ... )
StudentSick ( StudentID INT, SickDay DATETIME, IsValidated BOOL )

 

SELECT s.FirstName, s.LastName, CASE ss.IsValidated WHEN 1 THEN 'Yes' ELSE 'No' END AS Validated
FROM Student s
JOIN StudentSick ss ON s.StudentID = ss.StudentID
WHERE ss.SickDay >= DATE_SUB(NOW(), INTERVAL 48 HOUR)

 

~juddster

 

ok that looks like what i need.

 

whats IsValidated BOOL

and the echo would be what?
$q3=SELECT s.FirstName, s.LastName, CASE ss.IsValidated WHEN 1 THEN 'Yes' ELSE 'No' END AS Validated
FROM Student s
JOIN StudentSick ss ON s.StudentID = ss.StudentID
WHERE ss.SickDay >= DATE_SUB(NOW(), INTERVAL 48 HOUR);
$res3 = mysql_query($q3);
$row3 = mysql_fetch_assoc($res3);

<?php echo $row3['Validated'] ?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.