seetz10
03-01-2004, 11:49 AM
Here is some code that I am having alot of trouble with, and i can't seem to
figure what what i am doing wrong.
i want to print out a table. a cell should display 'B' if the query in the database returns a result
showing that there is a match. Or a cell should display 'A' if the query returns an empty set.
At the moment, all the cells show 'A' even though there are entries in the database that match.
I suspect an error in the loop somewhere, but i don't know where.
Please can anyone help??
thanks
while ($new_fday <= $tday)
{
$make_date = date ("j/n/Y", mktime(0,0,0,$fmonth,$new_fday,$fyear));
echo "<tr><td><b>$make_date</b></td>";
while($fromtimex < $totime)
{
$conn = mysql_connect();
mysql_select_db("test", $conn);
$sql = "SELECT bookingid FROM booking WHERE roomnum = '$roomsel' and
startdate = '$make_date' and (('$fromtimey' between starttime and endtime)
or starttime = '$fromtimey')";
$result = mysql_query($sql, $conn) or die(mysql_error());
$num = mysql_num_rows($result); // Count number of matching rows
if($num>0)
{
echo "<td>B</td>";
}
else
{
echo "<td>A</td>";
}
/*echo "<td> </td>";*/
$fromtimex = $fromtimex +1;
}
$new_fday = $new_fday +1;
echo "</tr>";
$fromtimex = $fromtimey;
}/*end while*/
echo "</table>";
figure what what i am doing wrong.
i want to print out a table. a cell should display 'B' if the query in the database returns a result
showing that there is a match. Or a cell should display 'A' if the query returns an empty set.
At the moment, all the cells show 'A' even though there are entries in the database that match.
I suspect an error in the loop somewhere, but i don't know where.
Please can anyone help??
thanks
while ($new_fday <= $tday)
{
$make_date = date ("j/n/Y", mktime(0,0,0,$fmonth,$new_fday,$fyear));
echo "<tr><td><b>$make_date</b></td>";
while($fromtimex < $totime)
{
$conn = mysql_connect();
mysql_select_db("test", $conn);
$sql = "SELECT bookingid FROM booking WHERE roomnum = '$roomsel' and
startdate = '$make_date' and (('$fromtimey' between starttime and endtime)
or starttime = '$fromtimey')";
$result = mysql_query($sql, $conn) or die(mysql_error());
$num = mysql_num_rows($result); // Count number of matching rows
if($num>0)
{
echo "<td>B</td>";
}
else
{
echo "<td>A</td>";
}
/*echo "<td> </td>";*/
$fromtimex = $fromtimex +1;
}
$new_fday = $new_fday +1;
echo "</tr>";
$fromtimex = $fromtimey;
}/*end while*/
echo "</table>";