bruckerrlb Posted May 4, 2010 Share Posted May 4, 2010 I'm working on making a calendar, basically the first part is set up where a user selects a service. There is a table in the DB for times which uses the service as an identifier. What I'm doing to make this calendar is I'm looping the days of the week and I've got the loop down but I'm not sure how I can put my dates in a variable and check to see when the variable is called if I need to put that in or not. My code should make a little more sense <h3>Schedule a time and a day</h3> <p>Click on the time that you would like to set up your appointment</p> <table border="3"><tr> <?php session_start(); $service_id = $_SESSION['service_id']; //have the service_id stored in a session /////////////select all time for service id call back time $spct = mssql_init('pctimecallback'); mssql_bind($spct, "@service_id", $service_id, SQLVARCHAR); $result = mssql_execute($spct) or die('MSSQL error: ' . mssql_get_last_message()); //variables to put into string $row = mssql_fetch_array($result); $mon = $row['mon']; $tue = $row['tue']; $wed = $row['wed']; $thurs = $row['thurs']; $fri = $row['fri']; $sat = $row['sat']; $sun = $row['sun']; $mon_start = $row['mon_start']; $mon_end = $row['mon_end']; $tue_start = $row['tue_start']; $tue_end = $row['tue_end']; $wed_start = $row['wed_start']; $wed_end = $row['wed_end']; $thur_start = $row['thur_start']; $thur_end = $row['thur_end']; $fri_start = $row['fri_start']; $fri_end = $row['fri_end']; $sat_start = $row['sat_start']; $sat_end = $row['sat_end']; $sun_start = $row['sun_start']; $sun_end = $row['sun_end']; ///////first for loop $days = 0; $maxdays = 6; while($days < $maxdays) { $day = date('M d', time() + $days * 86400); ?> <td id="<?php echo $day; ?>"><?php echo $day; ?></td> <?php $days++; } ?> </tr><tr> <?php //second for loop displaying the day $days0 = 0; $maxdays0 = 6; while($days0 < $maxdays0) { $theday = date('D', time() + $days0 * 86400); $theday = strtolower($theday); ?> <td><?php echo $theday; ?></td> <?php $days0++; } ?> </tr><tr> <?php //third for loop to do a test on variables $days1 = 0; $maxdays1 = 6; while($days1 < $maxdays1) { $theday1 = date('D', time() + $days1 * 86400); $theday1 = strtolower($theday1); $start_1 = $theday1; $start_2 = "_start"; $a_start = $start_1.$start_2; $end_1 = $theday1; $end_2 = "_end"; $a_end = $end_1.$end_2; //main variables for time here are $theday1, a_start, a_end, now find a way to pass over the service that was selected!!!!!!!!! ?> <td><?php echo $a_start; ?> and <?php echo $a_end; ?></td> <?php $days1++; } ?> </tr> </table> Can anyone show me how to put my variables for example $mon, $mon_start, $mon_end to check and see if it has data, and if it does, how to properly echo it in the for each statement. If that doesn't work, a better way of doing it? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.