Now why wont this code work?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
3.14
Forum Commoner
Posts: 28
Joined: Mon Sep 08, 2003 12:17 am

Now why wont this code work?

Post 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? :?
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post 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.
3.14
Forum Commoner
Posts: 28
Joined: Mon Sep 08, 2003 12:17 am

Post 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.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post 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.
3.14
Forum Commoner
Posts: 28
Joined: Mon Sep 08, 2003 12:17 am

Post 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.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Font tag is deprecated: better to use CSS styles, eg:

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