subashshakya1 / JEWEL_SOFT

0 stars 0 forks source link

Never embed html inside PHP #3

Open sodhancha opened 8 years ago

sodhancha commented 8 years ago
if(mysql_num_rows($result) > 0) {
    `while ($row = mysql_fetch_array($result)) {
        echo "<tr>";
        echo "<td>" . $row['cust_id'] . "</td>";
        echo "<td>" . $row['cust_name'] . "</td>";
        echo "<td>" . $row['address'] . "</td>";
        echo "<td>" . $row['ph_no'] . "</td>";
        echo "</tr>";
    }
}

Instead do this:

<? if(mysql_num_rows($result) > 0) :
    while ($row = mysql_fetch_array($result)): ?>
        <tr>
        <td> <?= $row['cust_id'] ?></td>
        <td> <?= $row['cust_name'] ?></td>
        <td> <?= $row['address'] ?></td>
        <td> <?= $row['ph_no'] ?></td>
        </tr>
  <?  endwhile;
endif; ?>
subashshakya1 commented 8 years ago

thanks a lot.... i'll not embed html inside php from now on...