Page 1 of 1

adding <tr> if something is TRUE??

Posted: Sat Dec 31, 2005 10:11 am
by atronmania
Hi everyone,
lets says i have this:

<table>
<tr>
<td>xyz <?php echo $row['ras1']; ?><span > ;</span>xyz <?php echo $row['ras2']; ?></td>
</tr>
</table>


I want this <tr> to be visible only when $row['ras1']!=""
otherwise it should not echo this TR!!!

any ideas???

Posted: Sat Dec 31, 2005 11:48 am
by jayshields
a simple if statement can be used to accomplish this. replace your current snippet with this:

Code: Select all

<table> 
  <?php
    if ($row['ras1'] != "") {
      echo "<tr>
      <td>xyz {$row['ras1']} <span > ;</span>xyz {$row['ras2']}</td>
      </tr>";
    }
  ?>
</table>

Posted: Sun Jan 01, 2006 1:49 am
by atronmania
That easy, ha???? thank you!

is there a tutorial or something to show how to avoid errors for writing the "html code" with "echo"??

I mean what if i'd like to echo something much complex like this:
<a href="../OLD/font/datapc/0-9/5x5dots.zip"><img src="image/0.gif" width="42' height="36" border="0" hspace="6" vspace="5"></a>


And a Happy new year to you all! 2006 is here!! :lol:

Posted: Sun Jan 01, 2006 2:22 am
by IAD
<a href="../OLD/font/datapc/0-9/5x5dots.zip"><img src="image/0.gif" width="42" height="36" border="0" hspace="6" vspace="5"></a>

There's no problem, just instead of "" qoute use ' ' .

here:

Code: Select all

echo '<a href="../OLD/font/datapc/0-9/5x5dots.zip"><img src="image/0.gif" width="42" height="36" border="0" hspace="6" vspace="5"></a> ';
Happy new year..

Jcart | Fixed parse error :0

Posted: Sun Jan 01, 2006 6:43 am
by atronmania
awesome!

Posted: Sun Jan 01, 2006 8:27 am
by jayshields
sorry i missed the closing curly brace. ive editted my previous post now.

Posted: Sun Jan 01, 2006 12:56 pm
by MaNiAC
Or you could escape it.

Code: Select all

echo "Escape this \" and now i'll add a meal: $meal.. this will work only within double \", you can also do this: ".$meal." see?";