cjrose77 Posted April 5, 2011 Share Posted April 5, 2011 Here is a link to the website I am designing. http://173.167.65.189/singleton/ the username and password is ksingleton at the bottom where the calendar is the query is searching for scheduled events, i am only posting the company_id right now, the problem I am having is I want a scheduled event that continues through the week to stay in line with the one before. But if the schedule before ended and a new one continues it moves the next date company_id up. How can i align the table rows or create an empty table row on all other days if there was a schedule before. here is the code for the calendar. <?php $db = new mysqli(); $setdate=strtotime($_GET['date']); $session=$_GET['session']; $calview=$_GET['calview']; if ($setdate <> "") { $date=$setdate; } else { $date=time(); } $day=date('d',$date); $month=date('m',$date); $year=date('Y',$date); $first_day=mktime(0,0,0,$month,1,$year); $title=date('F',$first_day); $day_of_week = date('D', $first_day); switch($day_of_week) { case "Sun": $blank = 0;break; case "Mon": $blank = 1;break; case "Tue": $blank = 2;break; case "Wed": $blank = 3;break; case "Thu": $blank = 4;break; case "Fri": $blank = 5;break; case "Sat": $blank = 6;break; } $days_in_month = cal_days_in_month(0, $month, $year); echo "<table cellpadding=0 cellspacing=0 border=0>"; echo "<tbody>"; echo "<tr>"; echo "<td><a href=?session=$session&calview=day>Day</a></td>"; echo "<td><a href=?session=$session&calview=week>Week</a></td>"; echo "<td><a href=?session=$session&calview=month>Month</a></td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=3>"; if ($calview=="month") { echo "<table border=1 width=800>"; echo "<tbody>"; echo "<tr height=25><th colspan=7> $title $year </th></tr>"; echo "<tr height=25><td width=58 align=center>Sunday</td><td width=58 align=center>Monday</td><td width=58 align=center>Tuesday</td><td width=58 align=center>Wednesday</td><td width=58 align=center>Thursday</td><td width=58 align=center>Friday</td><td width=58 align=center>Saturday</td></tr>"; $day_count = 1; echo "<tr height=50>"; while ( $blank > 0 ) { echo "<td></td>"; $blank = $blank-1; $day_count++; } $day_num = 1; while ($day_num <= $days_in_month ) { $newdate = $month ."/". $day_num ."/". $year; $msqlnewdate = date('m/d/Y',strtotime($newdate)); echo "<td valign=top><table cellpadding=0 cellspacing=0 border=0><tr><td><a href=?session=$session&calview=day&date=$newdate> $day_num </a></td></tr>"; $db = new mysqli('localhost','username','password', 'rsdata'); if (!$db) { echo 'ERROR: Could not connect to database.'; } else { $query = $db->query("SELECT * FROM rentals WHERE date_format(str_to_date(pdate_out,'%Y-%m-%d'), '%m/%d/%Y') <= '$msqlnewdate' AND date_format(str_to_date(pdate_in, '%Y-%m-%d'), '%m/%d/%Y') >= '$msqlnewdate'"); if ($query) { while ($result = $query->fetch_object()) { echo "<tr><td>".$result->company_id."</td></tr>"; } } echo "</table>"; } $day_num++; $day_count++; if ($day_count > 7) { echo "</tr><tr>"; $day_count=1; } } while ($day_count >1 && $day_count <=7 ) { echo "<td></td>"; $day_count++; } echo "</tr></table>"; } else if ($calview=="week") { } else { } echo "</td>"; echo "</tr>"; echo "</tbody>"; echo "</table>"; ?> MOD EDIT: DB credentials edited out. Quote Link to comment https://forums.phpfreaks.com/topic/232765-line-up-table-rows-for-found-data/ Share on other sites More sharing options...
cjrose77 Posted April 5, 2011 Author Share Posted April 5, 2011 and please don't hack my site, i just need help, i know usernames and passwords are shown, just don't want to change them if i don't have to Quote Link to comment https://forums.phpfreaks.com/topic/232765-line-up-table-rows-for-found-data/#findComment-1197246 Share on other sites More sharing options...
Pikachu2000 Posted April 5, 2011 Share Posted April 5, 2011 Well it's up to you, but I don't think I'd post my database credentials on the internet and trust that people won't use them maliciously just because I've asked them not to. Quote Link to comment https://forums.phpfreaks.com/topic/232765-line-up-table-rows-for-found-data/#findComment-1197248 Share on other sites More sharing options...
cjrose77 Posted April 5, 2011 Author Share Posted April 5, 2011 your right i edited the post Quote Link to comment https://forums.phpfreaks.com/topic/232765-line-up-table-rows-for-found-data/#findComment-1197251 Share on other sites More sharing options...
cjrose77 Posted April 5, 2011 Author Share Posted April 5, 2011 shoot still left it in there, how do i modify the original post Quote Link to comment https://forums.phpfreaks.com/topic/232765-line-up-table-rows-for-found-data/#findComment-1197256 Share on other sites More sharing options...
Pikachu2000 Posted April 5, 2011 Share Posted April 5, 2011 I took care of it for you. Quote Link to comment https://forums.phpfreaks.com/topic/232765-line-up-table-rows-for-found-data/#findComment-1197264 Share on other sites More sharing options...
cjrose77 Posted April 5, 2011 Author Share Posted April 5, 2011 thank you Quote Link to comment https://forums.phpfreaks.com/topic/232765-line-up-table-rows-for-found-data/#findComment-1197268 Share on other sites More sharing options...
cjrose77 Posted April 5, 2011 Author Share Posted April 5, 2011 nevermind, you can close this, got it figured out, thanks Quote Link to comment https://forums.phpfreaks.com/topic/232765-line-up-table-rows-for-found-data/#findComment-1197320 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.