how to add a table ?
Moderator: General Moderators
how to add a table ?
how do i put a complete table in here?
<?
if(strlen($site_rtttl)>260) {
echo "Deze bevat meer dan 50 tonen";
} else {
echo "Deze ringtone is helemaal gratis!";
}
?>
like this
<?
if(strlen($site_rtttl)>260) {
echo "<table width="85%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td class="tekst">
<div align="center"><a href="http://www.ringtone-zone.nl/top/rate.php?site=<? echo $id; ?>"><img src="vote.gif" width="150" height="40" border="0"></a></div>
</td>
<td class="tekst">
<div align="center"><a href="http://www.ringtone-zone.nl/top/recommend.php?site=<? echo $id; ?>"><img src="mail.png" width="150" height="40" border="0"></a></div>
</td>
<td class="tekst">
<div align="center"><a href="http://www.ringtone-zone.nl/top/review.php?site=<? echo $id; ?>"><img src="review.png" width="150" height="40" border="0"></a></div>
</td>
</tr>
</table>";
} else {
echo "Deze ringtone is helemaal gratis!";
}
?>
<?
if(strlen($site_rtttl)>260) {
echo "Deze bevat meer dan 50 tonen";
} else {
echo "Deze ringtone is helemaal gratis!";
}
?>
like this
<?
if(strlen($site_rtttl)>260) {
echo "<table width="85%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td class="tekst">
<div align="center"><a href="http://www.ringtone-zone.nl/top/rate.php?site=<? echo $id; ?>"><img src="vote.gif" width="150" height="40" border="0"></a></div>
</td>
<td class="tekst">
<div align="center"><a href="http://www.ringtone-zone.nl/top/recommend.php?site=<? echo $id; ?>"><img src="mail.png" width="150" height="40" border="0"></a></div>
</td>
<td class="tekst">
<div align="center"><a href="http://www.ringtone-zone.nl/top/review.php?site=<? echo $id; ?>"><img src="review.png" width="150" height="40" border="0"></a></div>
</td>
</tr>
</table>";
} else {
echo "Deze ringtone is helemaal gratis!";
}
?>
if you start a string literal with a double quote you have to escape double quotes within the contents. Php will stop the literal at the next unescaped double quote, e.g.
Within double quoted literals variables are substituted, e.g.as long as you do not need this feature you might use single quoted literals and use " in there freely, e.g.
take a look at these three examples (that should do almost the same but are untested)
I prefer the last one...
see also: http://www.php.net/manual/en/language.types.string.php
php will only take "<table width=" as literal trying to parse 85% as the next statement (which doesn't work). Escaping the special meaning of a character is done by prepending a \echo "<table width="85%" border="0" cellspacing="0" cellpadding="0" align="center">
Code: Select all
<?php ...
echo "<table width="85%" border="0" cellspacing="0" cellpadding="0" align="center">"
... ?>Code: Select all
<?php
$myVar = '12345';
echo "the value of myVar is: $myVar";
?>Code: Select all
<?php ...
echo '<table width="85%" border="0" cellspacing="0" cellpadding="0" align="center">';
...
?>this does not work when you're inside a literal. But you might leave the php block. Anything outside a php-block is sent as-is to the client.<? echo $id; ?>
take a look at these three examples (that should do almost the same but are untested)
Code: Select all
<?php // double quoted literals
$myVar = 'just an example';
echo "<table width="100%">
<tr>
<td>$myVar</td>
</tr>
</table>";
?>Code: Select all
<?php // single quoted literals
$myVar = 'just an example';
// echo can take multiple arguments, each added to the output stream
echo '<table width="100%">
<tr>
<td>', $myVar, '</td>
</tr>
</table>';
?>Code: Select all
<?php // leaving the php-block for (almost) static html
$myVar = 'just an example';
?>
<table width="100%">
<tr>
<td><?php echo $myVar; ?></td>
</tr>
</table>see also: http://www.php.net/manual/en/language.types.string.php
i got the table working
but when i isert the rtttl url it goes wrong
<?
if(strlen($site_rtttl)>200) {
echo '<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center" bordercolor="#000000">
<tr>
<td class="tekst3b">
<div align="center"> <font color="#0000FF"> <font size="4" color="#FF0000">WAARSCHUWING!<br>
<font color="#000000" size="2">Deze ringtone bevat
meer dan 50 tonen<br>
Bij een aantal telefoons kun je deze niet helemaal
invoeren<br>
Maar wees gerust met <b><a href="javascript:mobilemoneysale('<? echo $site_rtttl ?>','<? echo $site_naam ?>')" target="_self"><font size="3" color="#FF0000">verzenden</font></a></b>
krijg je het wel helemaal </font></font></font></div>
</td>
</tr>
</table>';
} else {
echo "";
}
?>
but when i isert the rtttl url it goes wrong
<?
if(strlen($site_rtttl)>200) {
echo '<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center" bordercolor="#000000">
<tr>
<td class="tekst3b">
<div align="center"> <font color="#0000FF"> <font size="4" color="#FF0000">WAARSCHUWING!<br>
<font color="#000000" size="2">Deze ringtone bevat
meer dan 50 tonen<br>
Bij een aantal telefoons kun je deze niet helemaal
invoeren<br>
Maar wees gerust met <b><a href="javascript:mobilemoneysale('<? echo $site_rtttl ?>','<? echo $site_naam ?>')" target="_self"><font size="3" color="#FF0000">verzenden</font></a></b>
krijg je het wel helemaal </font></font></font></div>
</td>
</tr>
</table>';
} else {
echo "";
}
?>
take a look at how this looks if passed through the syntaxhighlighterlooks strange, doesn't it?
Let's start with something simple, a static htmlnow add some phpthe <?php ?> tags tell the parser that what's inside is php. Everything outside will be passed as-is. Note the different colours used. Black is as-is output.
When you're in a php-block there's no nedd to open another block (in fact it's not allowed)see that the second ?> is black - the parser is confused...
Within a single quoted literal you have to escape single quotes if they are part of the contents. The same as with double quotes in a double quoted literal. There's no magic that tells php what you want to be in- and outside a literal - except syntax
it's probably easier to leave the php-block here and re-enter it when needed(maybe I messed with the font tags)
Code: Select all
<?
if(strlen($site_rtttl)>200) {
echo '<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center" bordercolor="#000000">
<tr>
<td class="tekst3b">
<div align="center"> <font color="#0000FF"> <font size="4" color="#FF0000">WAARSCHUWING!<br>
<font color="#000000" size="2">Deze ringtone bevat
meer dan 50 tonen<br>
Bij een aantal telefoons kun je deze niet helemaal
invoeren<br>
Maar wees gerust met <b><a href="javascript:mobilemoneysale('<? echo $site_rtttl ?>','<? echo $site_naam ?>')" target="_self"><font size="3" color="#FF0000">verzenden</font></a></b>
krijg je het wel helemaal </font></font></font></div>
</td>
</tr>
</table>';
} else {
echo "";
}
?>Let's start with something simple, a static html
Code: Select all
<html>
<head><title>an example</title></head>
<body>
&nbsp;
</body>
</html>Code: Select all
<html>
<head><title>an example</title></head>
<body>
<?php echo phpversion(); ?>
</body>
</htmlWhen you're in a php-block there's no nedd to open another block (in fact it's not allowed)
Code: Select all
<?php
/** This won't work */
echo 'something', <?php echo $something; ?>;
?>Within a single quoted literal you have to escape single quotes if they are part of the contents. The same as with double quotes in a double quoted literal. There's no magic that tells php what you want to be in- and outside a literal - except syntax
it's probably easier to leave the php-block here and re-enter it when needed
Code: Select all
<?php
if(strlen($site_rtttl)>200) {
?>
<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center" bordercolor="#000000">
<tr>
<td class="tekst3b">
<div align="center">
<font color="#0000FF">
<font size="4" color="#FF0000">WAARSCHUWING!<br /></font />
</font>
<font color="#000000" size="2">
Deze ringtone bevat meer dan 50 tonen<br />
Bij een aantal telefoons kun je deze niet helemaal invoeren<br />
Maar wees gerust met
<b>
<a href="javascript:mobilemoneysale('<?php echo $site_rtttl; ?>,<?php echo $site_naam; ?>');" target="_self">
<font size="3" color="#FF0000">verzenden</font>
</a>
</b>
krijg je het wel helemaal
</font>
</div>
</td>
</tr>
</table>
<?php
} else {
echo "";
}
?>oh, there's one more thing I shouldn't keep back only because of preference for leaving php-blocks 
http://www.php.net/manual/en/language.t ... ax.heredocBut that doesn't seperate php from html. Do you see where your php-variables are needed? It's all blue now 

http://www.php.net/manual/en/language.t ... ax.heredoc
Code: Select all
<?php
$site_rtttl = str_repeat('abcd', 90);
$site_naam = 'blub';
if(strlen($site_rtttl)>200) {
echo <<<EOD
<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center" bordercolor="#000000">
<tr>
<td class="tekst3b">
<div align="center">
<font color="#0000FF">
<font size="4" color="#FF0000">WAARSCHUWING!<br /></font />
</font>
<font color="#000000" size="2">
Deze ringtone bevat meer dan 50 tonen<br />
Bij een aantal telefoons kun je deze niet helemaal invoeren<br />
Maar wees gerust met
<b>
<a href="javascript:mobilemoneysale('$site_rtttl','$site_naam');" target="_self">
<font size="3" color="#FF0000">verzenden</font>
</a>
</b>
krijg je het wel helemaal
</font>
</div>
</td>
</tr>
</table>
EOD;
} else {
echo "";
}
?>Code: Select all
<?php
$site_rtttl = str_repeat('abcd', 90);
$site_naam = 'blub';
if(strlen($site_rtttl)>200) {
echo <<<EOD
<table width="95%/" border="0/" cellspacing="0"/ cellpadding="0/" align="center/" bordercolor="#000000/">
<tr>
<td class="tekst3b/">
<div align="center/">
<font color="#0000FF"/>
<font size="4/" color="#FF0000/">WAARSCHUWING!<br /></font />
</font>
<font color="#000000/" size="2/">
Deze ringtone bevat meer dan 50 tonen<br />
Bij een aantal telefoons kun je deze niet helemaal invoeren<br />
Maar wees gerust met
<b />
<a href="javascript:mobilemoneysale('$site_rtttl','$site_naam');" target="_self">
<font size="3" color="#FF0000">verzenden</font>
</a>
</b>
krijg je het wel helemaal
</font>
</div>
</td>
</tr>
</table>
EOD;
} else {
echo "";
}
?>