[prog] php and if/else statements

wolf wolf at wolfrising.net
Tue Dec 23 00:27:02 EST 2003


Hi, this time it's a PHP question : )


I have some code for a web page that basically populates a table with 
the term number, term and year, this was what I was currently using:


   <?php do { ?>
   <tr> </tr>
  <td><?php echo $row_Term_Number['term_number'];?></td>
     <td> <?php echo $row_Term_Number['term'];?>&nbsp;<?php echo 
$row_Term_Number['year'];?></td>

   <?php } while ($row_Term_Number = mysql_fetch_assoc($Term_Number)); ?>


I wanted to switch it over to an if statement so that for the 0 term it 
would print out TC/EC for the term instead of 0000 and print
a blank space for the term # instead of 0

The table currently reads:
Term #    Term
    0            0000
    1           Fall 2003
    2           Winter 2004

New idea;
Term #    Term
                 TC/EC
    1           Fall 2003
    2           Winter 2004


so this is what I was trying but I can already tell I've wandered off 
track. The mysql statement attached is definitely correct and
the original code worked, it's my newest idea that's crashing to the 
ground.  Does any one have any ideas on how this
might actually work? Or is it not possible to change it over ?  As 
always, thank you : )


<?php
if ($row_Term_Number['term_number'] == 0) {
  echo "<td>" "&nbsp;" "</td>" "<td>" TC/EC "</td>"

  } else  { ?>

<tr> </tr>
  <td><?php echo $row_Term_Number['term_number'];?></td>
     <td> <?php echo $row_Term_Number['term'];?>&nbsp;<?php echo 
$row_Term_Number['year'];?></td>

   <?php } while ($row_Term_Number = mysql_fetch_assoc($Term_Number)); ?>


More information about the Programming mailing list