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???
adding <tr> if something is TRUE??
Moderator: General Moderators
-
atronmania
- Forum Newbie
- Posts: 5
- Joined: Sat Dec 31, 2005 3:37 am
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
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>
Last edited by jayshields on Sun Jan 01, 2006 8:27 am, edited 1 time in total.
-
atronmania
- Forum Newbie
- Posts: 5
- Joined: Sat Dec 31, 2005 3:37 am
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!!
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!!
<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:
Happy new year..
Jcart | Fixed parse error :0
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> ';Jcart | Fixed parse error :0
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
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?";