Click to See Complete Forum and Search --> : PHP excape characters not working
Nibinaear
December 27th, 2004, 06:13 PM
This is my script, but when I run it, no tab characters are placed where I want them, what am I doing wrong?
<html>
<head>
<title> </title>
</head>
<body>
<?
include 'odbc_connection.php';
$query = odbc_exec($odbc, "SELECT * FROM student");
while($record = odbc_fetch_array($query))
{
echo "ID: ".$record['id']."\t";
echo "Name: ".$record['name']."\t";
echo "Age: ".$record['age']."\t";
echo "Address: ".$record['address']."\t";
echo "Phone_number: ".$record['Phone_number']."<p>";
}
?>
</body>
</html>
khp
December 27th, 2004, 06:45 PM
I would suspect that PHP is generating your tab characters. The problem is most likely that in html all whitespace characters are rendered as normal a normal space character.
You can work around this, by wrapping your output in <pre>...</pre> tags (for pre formatted text). Which renders newline and tab characters as such.
visualAd
December 28th, 2004, 03:48 AM
There is no way of getting tabs in HTML other than using the preformatted text tags like khp suggested. In a situation like yours it is easier to create a table, which has the same effect as the tabs.
Nibinaear
December 29th, 2004, 03:03 PM
It makes me wonder why the tab escape characters exist them, I've seen scripts on the web use them for a similar purpose.
khp
December 29th, 2004, 09:08 PM
It makes me wonder why the tab escape characters exist them, I've seen scripts on the web use them for a similar purpose.
There is a multitude of reasons.
PHP can be used for other things than producing html pages. And of course some people may prefer to make php code that produces 'pretty printed' html code, to makes the generated html code easier to read. For these purposes plus in <pre> tags creating tabs is quite usefull.
It's also quite usefull if you wish to match strings that contain tabs.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.