I am new to PHP but have set up PHP in Dreamweaver to connect to a MySQL database. I am wondering if it is possible to have the dynamic text formatted according to the content in the MySQL database, using PHP. For example - I have this if/then statement in PHP so if the content of Field1 = 0, then it displays FIELD1, else display FIELD2. <td> <?php if ($row_DATABASE['FIELD1']=="0") echo $row_DATABASE['FIELD1']; else echo $row_DATABASE['FIELD2'];?> </td> But what I am trying to do is format the color of the FIELD1 or FIELD2 based on the if/then statment. So maybe if displaying FIELD1, then font = red, else FIELD2, then font = blue.... I can put the class around the PHP text, but can't make it conditional: <td> <span class="style3"> <?php if ($row_DATABASE['FIELD1']=="0") echo $row_DATABASE['FIELD1']; else echo $row_DATABASE['FIELD2'];?> </span> </td> What I would like to do is something like this, but I get an error message because the <span> is in the PHP code. <td> <?php if ($row_DATABASE['FIELD1']=="0") <span class="style3"> echo $row_DATABASE['FIELD1'];</span> else echo $row_DATABASE['FIELD2'];?> </td> Any ideas on how to conditionally format dynamic text using PHP based on the actual content of the text???? Is this possible??? Thanks!!!
if you want to echo strings in php you should put it into the qoutes or double qoutes like this: <td> <?php if ($row_DATABASE['FIELD1']=="0") echo '<span class="style3">'.$row_DATABASE['FIELD1'].'</span>'; else echo $row_DATABASE['FIELD2'];?> </td> PHP: