Page 1 of 1

Now why wont this code work?

Posted: Wed Sep 17, 2003 11:02 pm
by 3.14
This bit of code works fine and displays in the normal ordinary boring times new roman font.. eeeugh!

Code: Select all

<?php

<td><?= $line['FirstName'] ?></td>

?>
Then I try this to change the font to arial and...

Code: Select all

<?php

<td><?= $line['<font face="Arial">LastName</font>'] ?></td>

?>
The column doesn't show up.

Even trying this

Code: Select all

<?php

<td><?= $line["<font face="Arial">'EmployeeID'</font>"] ?></td>

?>
Doesn't seem to work either. What am I doing wrong? Is hating default fonts that bad a crime against humanity that it won't let me change it? :?

Posted: Wed Sep 17, 2003 11:27 pm
by scorphus
Hi,
Could you please post the content of this $line array? Do:

Code: Select all

<?print_r($line)?>
and let us see what your array is like.

Regards,
Scorphus.

Posted: Wed Sep 17, 2003 11:42 pm
by 3.14
Ok, well the statement looks like this:

Code: Select all

<?php
while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
	{
?>
The output... with fake data is as follows:

Array ( [EmployeeID] => 1 [FirstName] => Frank [LastName] => Barns [Address] => 175 Kumble Way [Suburb] => Hilsdale [State] => WA [Postcode] => 6135 [Phone] => (08) 9247 7492 [StartDate] => 2001-04-10 [EndDate] => 0000-00-00 )

Of course that's just one element... all the others are identical in format.

Posted: Wed Sep 17, 2003 11:55 pm
by scorphus
Thanks :)

When you do:

Code: Select all

<td><?= $line['<font face="Arial">LastName</font>'] ?></td>
you're trying to get an invalid position of $line array ('<font face=\"Arial\">LastName</font>'). I would say you should change it to:

Code: Select all

<td><font face="Arial"><?= $line['LastName'] ?></font></td>
Now PHP can read the position 'LastName' of %line array and place it inside the <font></font> tag.

Or if you want PHP to print the <font> tag, we say:

Code: Select all

<td><?= '<font face="Arial">' . $line['LastName'] . '</font>' ?></td>
Hope it helps a bit...

Cheers,
Scorphus.

Posted: Thu Sep 18, 2003 12:02 am
by 3.14
Worked like a charm. Thanks :D

I'm surprised I missed the first option. The second option is something new though, so thanks for that.

Posted: Thu Sep 18, 2003 12:27 am
by McGruff
Font tag is deprecated: better to use CSS styles, eg:

<body style="font-family: arial, sans-serif;">