I have looked everywhere for help on this, and I cant find it anywhere.
I have written the code to print to an HTML page all the values of my database.
I have also written some IF ELSE blocks so that the data can be displayed in a neat manner.
BUT, when I put the two together, they dont work!
I have edited the code slightly, to fit the most important bits,
My code is as follows:
For the WHILE LOOP:
$db_print ="<table>";
WHILE ($row =mysql_fetch_array($result)) {
$id = $row['id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$b_name = $row['b_name'];
$address1 = $row['address1'];
$address2 = $row['address2'];
$address3 = $row['address3'];
$postcode = $row['postcode'];
$city = $row['city'];
$country = $row['country'];
$code_tel = $row['code_tel'];
$home_tel = $row['home_tel'];
$office_tel = $row['office_tel'];
$off2_tel = $row['off2_tel'];
$cell1_tel = $row['cell1_tel'];
$cell2_tel = $row['cell2_tel'];
$isdn_tel = $row['isdn_tel'];
$fax_tel = $row['fax_tel'];
$pager_tel = $row['pager_tel'];
$feed_tel = $row['feed_tel'];
$email_1 = $row['email_1'];
$spd_01 = $row['spd_04'];
$area_dep = $row['area_dep'];
$area_lead = $row['area_lead'];
$db_print .="<table width=\"95%\" border=\"1\"><tr align=\"top\"><td width=\"20\" bgcolor=\"#cccccc\"><strong>$area_dep $code_tel</strong></td><td width=\"10\" bgcolor=\"#cccccc\">Speed Dial</td><td width=\"50\" bgcolor=\"#cccccc\">Location</td><td width=\"100\" bgcolor=\"#cccccc\">Phone Number</td><td width=\"60\" bgcolor=\"#cccccc\">Notes</td></tr>".
"<tr valign=\"top\"><td>$f_name $l_name</td><td>$spd_01</td><td>Home</td><td>$home_tel</td><td>$notes_1</td></tr></table>";
}
$db_print .="</table>";
?>
If I try to put some IF blocks INTO the table data, then I get parse errors, an example of the IF block is:
<td><? IF ($spd_01 !="") {
ECHO "$spd_01";}
ELSEIF ($spd_01 =="") {
ECHO "$spd_06";}
?></td>
<td><? IF ($spd_01 !="") {
ECHO "Home";}
ELSEIF ($spd_01 =="") {
ECHO "Mobile";}
?></td>
<td><? IF ($spd_01 !="") {
ECHO "$home_tel";}
ELSEIF ($spd_01 =="") {
ECHO "$cell1_tel";}
?></td>
<td><? IF ($email_1 !="") {
ECHO "$email_1"; }
ELSE IF ($email_2 =="") {
ECHO "$notes_1";}
?></td>
</tr>
So When I try to put them together like this:
$db_print .="<table width=\"95%\" border=\"1\"><tr align=\"top\"><td width=\"20\" bgcolor=\"#cccccc\"><strong>$area_dep $code_tel</strong></td><td width=\"10\" bgcolor=\"#cccccc\">Speed Dial</td><td width=\"50\" bgcolor=\"#cccccc\">Location</td><td width=\"100\" bgcolor=\"#cccccc\">Phone Number</td><td width=\"60\" bgcolor=\"#cccccc\">Notes</td></tr>".
"<tr valign=\"top\"><td>$f_name $l_name</td><td>". IF ($spd_01 !="") { echo "$spd_01")} ."</td><td>3</td><td>4</td><td>5</td></tr></table>";
}
$db_print .="</table>";
?>
It doesnt work, I get a parse error, for the line with the IF commands on!
IF anyone has any ideas, then please help me, as I'm going crazy!
Thanks
John