Skip to content
Advertisement

php echo statement fails to execute

I am trying display data from mysql database from within an echo statement, but it crashes the webpage. I have tried many different ways to do the same, but it still fails every time here is the code.

        <?php

        ...

        echo '<td>'. $row["NAME"] . '</td>' .'<td>'. $row["DESIGNER"] . '</td>' .'<td>

         <form method="post"> 
         <table>
         <tr>                                                
         <td><input type="radio" name="site" value="none"'. if ($row["SELLING_ON"]=="none" ){echo 'checked';} .'>no site</td> 
                                                              ^^^^^THIS IS THE OFFENDING LINE^^^^^
         </tr>  
         </table>
         </form></td>

         <td>'. $row["MSRP_USED"] . '</td>' .'<td>'. $row["ORIGINAL_PRICE"] . '</td>' ;


         ...


         ?>

Look at the line where I say “this is the offending line.” As soon as I remove that line, everything works fine as it should.

Advertisement

Answer

Separate the if statement from the string

echo '<td>'. $row["NAME"] . '</td>' .'<td>'. $row["DESIGNER"] . '</td>' .'<td>

     <form method="post"> 
     <table>
     <tr>                                                
     <td><input type="radio" name="site" value="none"';
if ($row["SELLING_ON"]=="none" ){
echo 'checked';
}
echo '>no site</td></tr>  
     </table>
     </form></td>

     <td>'. $row["MSRP_USED"] . '</td>' .'<td>'. $row["ORIGINAL_PRICE"] . '</td>' ;
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement