Page 1 of 1

results in an table

Posted: Wed Jun 11, 2003 4:33 am
by z0rr0
hy to all
how do i do so my result (of an calculaton) wil be shown in table ???

here is a saple of the code that must apeare in the table :
}

echo "tabel siruri:<br>";
echo "$sir0<br>";
echo "$sir1<br>";
echo "$sir2<br>";
echo "$sir3<br>";
echo "$sir4<br>";
echo "$sir5<br>";
echo "$sir6<br>";
echo "$sir7<br>";
echo "$sir8<br>";
echo "$sir9<br>";
?>
thanks

Posted: Wed Jun 11, 2003 4:37 am
by []InTeR[]
Maybe a introduction to html is something for you?
I found a nice one.... An Introduction to HTML

Posted: Wed Jun 11, 2003 4:44 am
by z0rr0
hmm...so it works just like in html (i meen the <table .... > stuff is the same ) ? i am very new to php so...but i KNOW html :?

Posted: Wed Jun 11, 2003 4:47 am
by twigletmac
PHP doesn't replace HTML - you still need to use that to markup the code - PHP just makes it possible to generate dynamic pages with markup and contents changed without the need of hundreds of static pages.

Mac

Posted: Wed Jun 11, 2003 4:50 am
by volka
php only produces a stream of data, what ever it is ...php doesn't care about it.
By default (and until you change it) the content-type text/html is sent within the response-header, so usually the client should try to interpret the output as html; that's courtesy of the client but it will not notice the difference between

Code: Select all

echo '<html><body><pre>test</pre></body></html>';
and

Code: Select all

&lt;html&gt;&lt;body&gt;&lt;pre&gt;test&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;
because the output (and only the output is what the client gets) is (more or less) identical.
If you open your browser's source-view you will see the output of the script (ok, some headers e.g. with cookie-data might have been sent, too) and nothing more the client will see and/or interpret

Posted: Wed Jun 11, 2003 4:53 am
by z0rr0
thanks a lto

Posted: Wed Jun 11, 2003 5:01 am
by z0rr0
so something like this will work ????
echo "<table width="100%" cellspacing="0" cellpadding="0" border="0">";
echo "<tr>
<td>&nbsp;tabel siruri:</td>
</tr>";
echo "<tr>
<td>&nbsp;$sir0</td>
</tr>";

echo "$sir1<br>";
echo "$sir2<br>";
echo "$sir3<br>";
echo "$sir4<br>";
echo "$sir5<br>";
echo "$sir6<br>";
echo "$sir7<br>";
echo "$sir8<br>";
echo "$sir9<br>";
?>

Posted: Wed Jun 11, 2003 5:06 am
by volka
don't hesitate to try it ;)
echo "<table width="100%" cellspacing="0" cellpadding="0" border="0">";
if you start a string literal with a double quote php will parse anything up to next double quote as contents of the literal, but it will stop at the next ", so you will get a parse error. Take a look at the colors the syntax highlighter uses here

Code: Select all

echo "<table width="100%" cellspacing="0" cellpadding="0" border="0">";
echo "<tr>
<td> tabel siruri:</td>
</tr>";
echo "<tr>
<td> $sir0</td>
</tr>";
echo "$sir1<br>";
echo "$sir2<br>";
echo "$sir3<br>";
echo "$sir4<br>";
echo "$sir5<br>";
echo "$sir6<br>";
echo "$sir7<br>";
echo "$sir8<br>";
echo "$sir9<br>";
?>
As you can see the % of width="100%" has the same colour as the php-function echo, unlikely that this is correct ;)
But you can escape the special meaning of a character with backslashes; compare

Code: Select all

echo "<table width="100%" cellspacing="0" cellpadding="0" border="0">";
echo "<tr>
<td> tabel siruri:</td>
</tr>";
echo "<tr>
<td> $sir0</td>
</tr>";
echo "$sir1<br>";
echo "$sir2<br>";
echo "$sir3<br>";
echo "$sir4<br>";
echo "$sir5<br>";
echo "$sir6<br>";
echo "$sir7<br>";
echo "$sir8<br>";
echo "$sir9<br>";
?>
Now all string literals are monocoloured, as they should..

If you think this looks ugly I totally agree. If you do not need substitutions (like echo "and the winner is: $winner"; ) you can use single quote as delimeter

Code: Select all

echo '<table width="100%" cellspacing="0" cellpadding="0" border="0">';
echo '<tr>
<td> tabel siruri:</td>
</tr>';
echo "<tr>
<td> $sir0</td>
</tr>";
echo "$sir1<br>";
echo "$sir2<br>";
echo "$sir3<br>";
echo "$sir4<br>";
echo "$sir5<br>";
echo "$sir6<br>";
echo "$sir7<br>";
echo "$sir8<br>";
echo "$sir9<br>";
?>
there are some other styles but I think this should do for now ;)

Posted: Wed Jun 11, 2003 5:10 am
by z0rr0
thanks again

Posted: Wed Jun 11, 2003 6:01 am
by cactus
It's also worth giving the "Strings" manual page a read, which explains the use of quotes:

http://www.php.net/types.string

Regards,