[prog] Re: code assistance
Saint-Wolfe
wolf at wolfrising.net
Thu Oct 16 22:21:47 EST 2003
I think in the loop I need some sort of additional if statement to tell
it which row to choose, would anyone
happen to know how to construct this if statement?
// loop thru result
for($crow = 0; $crow < $numrows; $crow++) {
$res_array = mysql_fetch_assoc($result);
$period=$res_array['period'];
$status = $res_array['status'];
for($i = 0;$i < 5; $i++) {
for($j = 0; $j < 8; $j++) {
<--------------------- need additional if statement here?
if ( $grid[$i][$j][0] != "") {
} else {
$grid[$i][$j][0] = $status;
}
}
}
}
Full Code below if needed
<?php require_once('connect.php'); ?>
<?php
mysql_select_db($database_connect, $connect);
$query_Code = "SELECT s_code FROM attendance where s_code=$code";
$Code = mysql_query($query_Code, $connect) or die(mysql_error());
$totalRows_Code = mysql_num_rows($Code);
?>
<?
$query = "select s_code, term, year, UPPER(c_code) as course,
dayname(date) AS date, period, status from attendance where
s_code=193586498 and term='Fall' and year=2003 and date between
'2003-09-01'and '2003-09-05'";
// retrieve result set
$result = mysql_db_query("db",$query);
$numrows = mysql_num_rows($result);
// loop thru result
for($crow = 0; $crow < $numrows; $crow++) {
$res_array = mysql_fetch_assoc($result);
$period=$res_array['period'];
$status = $res_array['status'];
for($i = 0;$i < 5; $i++) {
for($j = 0; $j < 8; $j++) {
if ( $grid[$i][$j][0] != "") {
} else {
$grid[$i][$j][0] = $status;
}
}
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title> Screen</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<STYLE TYPE="text/css">
<!--
A {text-decoration:none}
//-->
</STYLE>
</head>
<body>
<BR> <br>
<? // load periods into array
$per[0] = "8:30 / 8:30";
$per[1] = "9:30 / 9:20";
$per[2] = "10:30 / 10:10";
$per[3] = "11:30 / 11:00";
$per[4] = "12:30 / 12:55";
$per[5] = "1:30 / 1:45";
$per[6] = "2:30 / 2:35";
$per[7] = "3:30 / 3:30";
$per[8] = "4:30 / 4:30";
?>
<div align="center">
<table width="70%" border="1" cellpadding="0" cellspacing="0"
id="schedule">
<tr>
<td bgcolor="#969663" width="20%" height="35"><div
align="center">MThF / TuWed</div></td>
<td bgcolor="#969663" width="16%"><div
align="center">Monday</div></td>
<td bgcolor="#969663" width="16%"><div
align="center">Tuesday</div></td>
<td bgcolor="#969663" width="16%"><div
align="center">Wednesday</div></td>
<td bgcolor="#969663" width="16%"><div
align="center">Thursday</div></td>
<td bgcolor="#969663" width="16%"><div
align="center">Friday</div></td>
</tr>
<?php
for( $j =0;$j <8;$j ++)
{
print("<tr align=center>\n");
print("<td bgcolor=969663>" . $per[$j] . "</td>");
for( $i =0;$i <5;$i ++) {
print("<td>\n");
if ($grid[$i][$j][0] == "") {
echo " ";
} else {
echo $grid[$i][$j][0];
}
print("</td>\n");
}
print("</tr>\n");
}
//print("</table>\n");
?>
</table>
</div>
</body>
</html>
<?php
mysql_free_result($Code);
?>
More information about the Programming
mailing list