He everyone! I am learning PHP and am new to coding in general - maybe PHP wasn't the best to start with, but I did 🙂
What I am trying to do is detect a variable out of a db and if it's one thing make the text bold, but if it's another it is normal. I am not having much luck with it, though. The if/else statement is logical enough to me, but apparently not to PHP because it apparently completely ignores it. Is there a problem with having an if/else statement inside the loop? Is there a better way to accomplish what I'm trying to do?
Any assistance would be awesome - thanks in advance!
- Michael
if ($myrow = mysql_fetch_array($result)) {
echo "<table width=780 border=0 cellspacing=5 align=center>\n";
do {
// display results in table //
printf("<tr>");
printf("<td width=77 align=center valign=middle>");
printf("<a href=\"%s\"><img src=%s border=0></a>\n", $myrow["link"], $myrow["thumbnail"]);
printf("</td><td width=68 align=center valign=middle>");
// detect if basic or premier, make bold if premier //
if ($myrow["bas_prem"]='premier') {
print "<b>";
} else {
print "";
}
printf("<font size=2><a href=\"%s\"><font color=#0000CC>%s</font></a></font>\n", $myrow["link"], $myrow["lstg_num"]);
if ($myrow["bas_prem"]='premier') {
print "</b>";
} else {
print "";
}
printf("</td><td width=135 valign=middle>");
if ($myrow["bas_prem"]='premier') {
print "<b>";
} else {
print "";
}
printf("<font size=2>%s<br>%s<br><font color=#FF0066><b>%s</b></font></font>\n", $myrow["address"], $myrow["area"], $myrow["open_house"]);
if ($myrow["bas_prem"]='premier') {
print "</b>";
} else {
print "";
}
printf("</td><td width=200 valign=middle>");
if ($myrow["bas_prem"]='premier') {
print "<b>";
} else {
print "";
}
printf("<font size=2>%s<br><font color=#FF0066><b>%s</b></font></font>\n", $myrow["description"], $myrow["descr_note"]);
if ($myrow["bas_prem"]='premier') {
print "</b>";
} else {
print "";
}
printf("</td><td width=70 align=center valign=middle>");
if ($myrow["bas_prem"]='premier') {
print "<b>";
} else {
print "";
}
printf("<font size=2>%s</font>\n", $myrow["bedrooms"]);
if ($myrow["bas_prem"]='premier') {
print "</b>";
} else {
print "";
}
printf("</td><td width=70 align=center valign=middle>");
if ($myrow["bas_prem"]='premier') {
print "<b>";
} else {
print "";
}
printf("<font size=2>%s</font>\n", $myrow["bathrooms"]);
if ($myrow["bas_prem"]='premier') {
print "</b>";
} else {
print "";
}
printf("</td><td width=99 align=right valign=middle>");
if ($myrow["bas_prem"]='premier') {
print "<b>";
} else {
print "";
}
printf("<font size=2>$%s<br><b><font color=#FF0066><b>%s</b></font></font>\n", $myrow["price"], $myrow["price_note"]);
if ($myrow["bas_prem"]='premier') {
print "</b>";
} else {
print "";
}
printf("</td></tr><tr><td height=2 colspan=7 bgcolor=#0000CC></td></tr>\n");
} while ($myrow = mysql_fetch_array($result));