Thanks guys for your input, i am trying to have it all in one table, but i am going crazy getting the logic to work here :S :/ maybe if i can explain the situation i can get some ideas from you? i would really appreciate it... this is the scenario..
all the alerts depend when the counselor is assigned..
1 table is `exp` here the counselor is assigned there is a table for each service that is required.. for example there are about 10 to 20 services..
the first alert should show up at 4:30 pm of the day the counselor is assigned..
so this is what i do when they update the table and assign a counselor i insert the first alert into the table `alerts` here all goes well. then this is how i get the first alert to show up
PHP Code:
$sql = "SELECT * FROM alert WHERE counselor = '$user' AND status = 'Active' ORDER BY date, time LIMIT 1";
$q = mysql_query($sql);
$row = mysql_fetch_array($q);
$alert_id = $row['id'];
$dtime = strtotime($row['date'] . " " . $row['time']);
$status = $row['status'];
$counselor = $row['counselor'];
$task = $row['task'];
$show = $row['show'] +1;
//alert one
if($ctime > $dtime && $status == "Active" && $counselor == $user){
$q = mysql_query("update `alert` set `show` = '$show' where `id` = '$alert_id'") or die(mysql_error());
echo "<script type='text/javascript'>window.open('alerts/alert_one.php?id=$alert_id&task=$task','user','height=660,width=680');</script>";
}
ok this where i am stocked the second alert needs to be 2 hours after the counselor is assigned and the field `req_voc` on table `voc` is == Yes
so what i was thinking is that everytime the save yes on `voc` table, i can add a field on alerts table and update it with the value yes.. but then again i can not update the record because is set up for the first alert i can not change the time.. :/ also i wont be able to update the table if the counselor has not been assigned yet :/ im going crazy here :/
|