while ($row = mysql_fetch_array($result))??????????
Posted: Wed Apr 13, 2005 2:22 pm
Hi all
I have problem with looping trough database, and creating year calendar of booking.
I know how to create calendar, but part that is confusing me is where to put
"while ($row = mysql_fetch_array($result))".
Here is complete code
I have problem with looping trough database, and creating year calendar of booking.
I know how to create calendar, but part that is confusing me is where to put
"while ($row = mysql_fetch_array($result))".
Here is complete code
Code: Select all
<?
$slobodno = " bgcolor=\"#00FF00\"";
$mogucnost = " bgcolor=\"#FFFF00\"";
$zauzeto = " bgcolor=\"#FF0000\"";
$font = "<font color=\"#000000\" size=\"2\" face=\"Times New Roman, Times, serif\">";
$godina="2005";
$smjestaj = '3521876818';
echo "<table width=\"70%\" border=\"1\" align=\"center\">";
echo "<tr>";
echo "<td width=\"5%\" align=\"center\" bgcolor=\"#3399FF\">$font Mjesec</td><td colspan=\"31\" bgcolor=\"#3399FF\"><div align=\"center\" > $font Dani</div></td></tr>";
include("stranice/con_db.php");
$result = mysql_query("select * from rezervacije where smjestaj ='$smjestaj'") or
die (mysql_error());
//while ($row = mysql_fetch_array($result)) //< ----------- WHERE TO PUT THIS LINE???
for ($i = 1; $i <= 12; $i++)
{
echo "<td align=\"center\" bgcolor=\"#3399FF\">" . $font . $i . "</td>";
$broj_dana = cal_days_in_month (CAL_GREGORIAN, $i, $godina);
for ($i1 = 1; $i1 <= $broj_dana; $i1++)
{
$dat_od = $row["od"];
$dat_do = $row["do"];
$status = $row["status"];
$datum11 = mktime(0, 0, 0, $i, $i1, $godina);
if (($datum11 >= $dat_od) and ( $datum11 <= $dat_do) and ($status == "zainteresiranost" )):
$ispis = "<td width=\"4%\" align=\"center\" $mogucnost> $font $i1</td>";
elseif (($datum11 >= $dat_od) and ( $datum11 <= $dat_do) and ($status == "rezervacija" )):
$ispis = "<td width=\"4%\" align=\"center\" $zauzeto> $font $i1</td>";
else:
$ispis = "<td width=\"4%\" align=\"center\" $slobodno>$font $i1</td>";
endif;
echo $ispis;
}
echo "</tr>";
}
mysql_free_result($result);
include("stranice/disconect.php");
echo "</table>";
echo "<br>";
echo $status;
echo "<table width=\"30%\" border=\"1\" align=\"center\">";
echo "<td width=\"10%\" align=\"center\" $mogucnost> $font Interes postoji</td>";
echo "<td width=\"10%\" align=\"center\" $slobodno> $font Slobodno</td>";
echo "<td width=\"10%\" align=\"center\" $zauzeto> $font Zauzeto</td></tr>";
echo "</table>";
?>