Display two records output to one html table row
Posted: Mon Aug 25, 2003 4:55 pm
Summary:
In helping a college student with a soccer site and I need to be able to display up to four records on one table row. In the web site's playing field reservation application, a registered coach may select a field number one and three at 1:00PM, leaving fields two and four open at that same time.
However, another registered coach may reserve field number two at 1:00 PM, thus leaving field number four open at the same time.
Issue:
The first 1:00PM record displays correctly and "marks" field one and three with a "pending" label at 1:00PM. However, the second 1:00PM record for the reserved field two shows up on a table row, with a "pending" label, directly beneath the first 1:00PM record. This makes sense, since it is two records in the table.
Question:
How do I show both records on one row, since both records are at the same time?
Any help or direction or samples are greatly appreciated!
Stats:
MySQL database
PHP Version 4.2.2
Tables:
#----------------------------
# Table structure for tblScheduleHours - table used to loop through the hours the facility is open each day
#----------------------------
create table tblScheduleHours (
SHID int(2) not null auto_increment,
Hours time not null default '00:00:00',
primary key (SHID))
type=MyISAM;
#----------------------------
# Records for table tblScheduleHours
# Military Time
#----------------------------
insert into tblScheduleHours values
(1, '06:00:00'),
(2, '07:00:00'),
(3, '08:00:00'),
(4, '09:00:00'),
(5, '10:00:00'),
(6, '11:00:00'),
(7, '12:00:00'),
(8, '13:00:00'),
(9, '14:00:00'),
(10, '15:00:00'),
(11, '16:00:00'),
(12, '17:00:00'),
(13, '18:00:00'),
(14, '19:00:00'),
(15, '20:00:00'),
(16, '21:00:00'),
(17, '22:00:00'),
(18, '23:00:00'),
(19, '24:00:00');
#----------------------------
# Table structure for tblSchedule - table used to store reservations
#----------------------------
create table tblSchedule (
SID int(50) not null auto_increment,
ReserveDate date,
TimeID int(2) not null default '0',
Reserveby int(10) not null default '0',
ReservedFlag int(4) not null default '0',
NW char(1),
NE char(1),
SW char(1),
SE char(1),
Trainer int(1) not null default '0',
primary key (SID))
type=MyISAM;
#----------------------------
# Records for table tblSchedule
#----------------------------
insert into tblSchedule values
(1, '2003-08-15', 7, 23, 1, '0', '0', '', '', 1),
(2, '2003-08-15', 7, 23, 1, '', '', '0', '', 0),
(3, '2003-08-20', 7, 23, 1, '', '', '0', '0', 1),
(4, '2003-08-20', 7, 23, 1, '', '0', '', '', 0);
Code:
In helping a college student with a soccer site and I need to be able to display up to four records on one table row. In the web site's playing field reservation application, a registered coach may select a field number one and three at 1:00PM, leaving fields two and four open at that same time.
However, another registered coach may reserve field number two at 1:00 PM, thus leaving field number four open at the same time.
Issue:
The first 1:00PM record displays correctly and "marks" field one and three with a "pending" label at 1:00PM. However, the second 1:00PM record for the reserved field two shows up on a table row, with a "pending" label, directly beneath the first 1:00PM record. This makes sense, since it is two records in the table.
Question:
How do I show both records on one row, since both records are at the same time?
Any help or direction or samples are greatly appreciated!
Stats:
MySQL database
PHP Version 4.2.2
Tables:
#----------------------------
# Table structure for tblScheduleHours - table used to loop through the hours the facility is open each day
#----------------------------
create table tblScheduleHours (
SHID int(2) not null auto_increment,
Hours time not null default '00:00:00',
primary key (SHID))
type=MyISAM;
#----------------------------
# Records for table tblScheduleHours
# Military Time
#----------------------------
insert into tblScheduleHours values
(1, '06:00:00'),
(2, '07:00:00'),
(3, '08:00:00'),
(4, '09:00:00'),
(5, '10:00:00'),
(6, '11:00:00'),
(7, '12:00:00'),
(8, '13:00:00'),
(9, '14:00:00'),
(10, '15:00:00'),
(11, '16:00:00'),
(12, '17:00:00'),
(13, '18:00:00'),
(14, '19:00:00'),
(15, '20:00:00'),
(16, '21:00:00'),
(17, '22:00:00'),
(18, '23:00:00'),
(19, '24:00:00');
#----------------------------
# Table structure for tblSchedule - table used to store reservations
#----------------------------
create table tblSchedule (
SID int(50) not null auto_increment,
ReserveDate date,
TimeID int(2) not null default '0',
Reserveby int(10) not null default '0',
ReservedFlag int(4) not null default '0',
NW char(1),
NE char(1),
SW char(1),
SE char(1),
Trainer int(1) not null default '0',
primary key (SID))
type=MyISAM;
#----------------------------
# Records for table tblSchedule
#----------------------------
insert into tblSchedule values
(1, '2003-08-15', 7, 23, 1, '0', '0', '', '', 1),
(2, '2003-08-15', 7, 23, 1, '', '', '0', '', 0),
(3, '2003-08-20', 7, 23, 1, '', '', '0', '0', 1),
(4, '2003-08-20', 7, 23, 1, '', '0', '', '', 0);
Code:
Code: Select all
<?php
$date = $_POSTї'txtDate'];
$qdate = $_GETї'qDate'];
if(isset($date)){
$date = $date;
$newdate = date("Y-m-d", strtotime($date));
} else {
$date = $qdate;
$newdate = date("Y-m-d", strtotime($date));
}
mysql_select_db($database_connCenter, $connCenter);
//$query_rsGetScheduleHours = "SELECT tblScheduleHours.SHID, tblScheduleHours.Hours, tblSchedule.SID, tblSchedule.ReserveDate, tblSchedule.TimeID, tblSchedule.ReservedFlag, tblSchedule.Reserveby, tblSchedule.NW, tblSchedule.NE, tblSchedule.SW, tblSchedule.SE, tblSchedule.Trainer FROM tblSchedule RIGHT OUTER JOIN tblScheduleHours ON (tblSchedule.TimeID = tblScheduleHours.SHID)";
$query_rsGetScheduleHours = "SELECT * FROM tblScheduleHours";
$rsGetScheduleHours = mysql_query($query_rsGetScheduleHours, $connCenter) or die(mysql_error());
$row_rsGetScheduleHours = mysql_fetch_assoc($rsGetScheduleHours);
$totalRows_rsGetScheduleHours = mysql_num_rows($rsGetScheduleHours);
function writeValue($intValue,$fieldname){
if($intValue == '1'){
$varWriteValue = "<font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif">Reserved</font>";
} elseif($intValue == '0') {
$varWriteValue = "<font color="#FF0000" size="2" face="Arial, Helvetica, sans-serif">Pending Res.</font>";
} else {
$varWriteValue = "$fieldname: <input name="cb$fieldname" type="checkbox" id="cb$fieldname" value="0">";
}
return $varWriteValue;
}
?>
<form action="process_reservation.php" method="post">
<table width="700" border="0" cellpadding="2" cellspacing="0">
<tr bgcolor="#CCCCCC">
<td align="center"><img src="../../images/reservfield/NW.gif" width="100" height="62"></td>
<td align="center"><img src="../../images/reservfield/SW.gif" width="100" height="62"></td>
<td align="center"><img src="../../images/reservfield/NE.gif" width="100" height="62"></td>
<td align="center"><img src="../../images/reservfield/SE.gif" width="100" height="62"></td>
<td align="center"><font size="2" face="Arial, Helvetica, sans-serif">Request
Trainer:</font></td>
<td align="center"><font size="2" face="Arial, Helvetica, sans-serif">Hours:</font></td>
</tr>
<?php
do {
mysql_select_db($database_connCenter, $connCenter);
$query_rsGetReservedTime = sprintf("SELECT * FROM tblSchedule WHERE tblSchedule.TimeID = '%s' AND tblSchedule.ReserveDate ='%s'", $row_rsGetScheduleHoursї'SHID'], $newdate);
$rsGetReservedTime = mysql_query($query_rsGetReservedTime, $connCenter) or die(mysql_error());
$row_rsGetReservedTime = mysql_fetch_assoc($rsGetReservedTime);
$totalRows_rsGetReservedTime = mysql_num_rows($rsGetReservedTime);
//----------------------------------------
$varStatusCheck = $row_rsGetReservedTimeї'ReservedFlag'];
//$duplicate;
do {
//if($row_rsGetReservedTimeї'TimeID'] != $duplicate){
if(!$varStatusCheck == 1){
?>
<tr bgcolor="<?php if ($BRB_rowcounter++%2==0){?>#FFFFFF<?php }else{ ?>#CCCCCC<?php }?>">
<td width="120" align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo "NW: <input name="cbNW" type="checkbox" id="cbNW" value="0">"; ?></font></td>
<td width="120" align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo "SW: <input name="cbSW" type="checkbox" id="cbSW" value="0">"; ?></font></td>
<td width="120" align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo "NE: <input name="cbNE" type="checkbox" id="cbNE" value="0">"; ?></font></td>
<td width="120" align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo "SE: <input name="cbSE" type="checkbox" id="cbSE" value="0">"; ?></font></td>
<td width="100" align="center"><font size="2" face="Arial, Helvetica, sans-serif">
<input name="trainer" type="checkbox" id="trainer" value="1">
</font></td>
<td width="100">
<input name="varDate" type="hidden" value="<?php echo $newdate; ?>">
<input name="varTime" type="radio" value="<?php echo $row_rsGetScheduleHoursї'SHID']; ?>">
<font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row_rsGetScheduleHoursї'Hours']; ?></font> </td>
</tr>
<?php } else { ?>
<tr bgcolor="<?php if ($BRB_rowcounter++%2==0){?>#FFFFFF<?php }else{ ?>#CCCCCC<?php }?>">
<td width="120" align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo writeValue($row_rsGetReservedTimeї'NW'],'NW'); ?></font></td>
<td width="120" align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo writeValue($row_rsGetReservedTimeї'SW'],'SW'); ?></font></td>
<td width="120" align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo writeValue($row_rsGetReservedTimeї'NE'],'NE'); ?></font></td>
<td width="120" align="center"><font size="2" face="Arial, Helvetica, sans-serif"><?php echo writeValue($row_rsGetReservedTimeї'SE'],'SE'); ?></font></td>
<td width="100" align="center"><font size="2" face="Arial, Helvetica, sans-serif">
<input name="trainer" type="checkbox" id="trainer" value="1">
</font></td>
<td width="100">
<input name="varTime" type="radio" value="<?php echo $row_rsGetScheduleHoursї'SHID']; ?>">
<font size="2" face="Arial, Helvetica, sans-serif"><?php echo $row_rsGetScheduleHoursї'Hours']; ?></font> </td>
</tr>
<?php
} //end if
//} //end if
//$duplicate = $row_rsGetReservedTimeї'TimeID'];
} while ($row_rsGetReservedTime = mysql_fetch_assoc($rsGetReservedTime));
?>
<?php
} while ($row_rsGetScheduleHours = mysql_fetch_assoc($rsGetScheduleHours));
?>
<tr>
<td colspan="6" align="right"><input name="varDate" type="hidden" value="<?php echo $newdate; ?>"><input name="btnSubmit" type="submit" value="Make Reservation..."></td>
</tr>
</table>
</form>