473,854 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP - Changing the font sizes of HTML output

12 New Member
Hi,

This is probably really simple to most of you but I have a PHP based website that I want to change the font (of the outputted HTML) and I'm really struggling! Here is a snippet of my code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. echo "<font face='arial' size='1'>";
  3.     echo "
  4.     <TABLE BORDER=1>
  5.     <TR>
  6.     <TH>Call Reference Number</TH>
  7.     <TH>Techncian</TH>
  8.     <TH>User</TH>
  9.     <TH>Call Description</TH>
  10.     <TH>Call Category</TH>
  11.     <TH>Call Priority</TH>
  12.     <TH>Call Resolution</TH>
  13.     <TH>Time Taken in hours</TH>
  14.     <TH>Time Taken in minutes</TH>
  15.     <TH>Date Logged</TH>
  16.     </TR>
  17.     </font>";
  18.  
  19. // Enter results in table
  20.  
  21. while ($row=mysql_fetch_array($sql_result)) {
  22.     $call_id=$row["Call_ID"];
  23.     $user=$row["User"];
  24.     $user_logged=$row["User_logged"];
  25.     $call_desc=$row["Call_Desc"];
  26.     $category=$row["Category"];
  27.     $priority=$row["Priority"];
  28.     $resolution=$row["Resolution"];
  29.     $time_hrs=stripslashes($row["Time_Hrs"]);
  30.     $time_mins=$row["Time_Mins"];
  31.     $date_logged=$row["Date_Logged"];
  32.  
  33.     echo "<font face='arial' size='1'>
  34.     <TR>
  35.     <TD><INPUT type=\"text\" readonly=\"readonly\" name =\"call_id\" value=\"$call_id\"></TD>
  36.     <TD>$user</TD>
  37.     <TD>$user_logged</TD>
  38.     <TD>$call_desc</TD>
  39.     <TD>$category</TD>
  40.     <TD>$priority</TD>
  41.     <TD>$resolution</TD>
  42.     <TD>$time_hrs</TD>
  43.     <TD>$time_mins</TD>
  44.     <TD>$date_logged</TD>
  45.     <TD>
  46.     <p align=center><INPUT type=\"submit\" value=\"Delete Call\"></p>
  47.     </TD>
  48.     </TR>
  49.     </font>"; 
  50.  
The font is changing to arial but I really can't get the font size to change. Can anyone help??

Thanks in advance.

Martin
Mar 30 '06 #1
15 40995
Banfa
9,065 Recognized Expert Moderator Expert
The problem you are having is because font size changes outside a table do not effect the font sizes inside the table cells. If you want to change the font sizes using the <font ... > tag you have to put one inside every table cell. This makes for very messy HTML.

However the good news is that there is now a better way all of the following tags are depricated

<font>
<basefont>
<b>
<i>

instead you should try using css (or the <strong> and <em> tags in place of <b> and <i>). With css you can applied a font size and style to all table cells with 1 small section of data at the top of you file. Try adding this to your output (I put in the <html>, <head> and <body> tags only so that you can tell where it should go in the file)

[html]
<html>
<head>
<style>
body {
font-size: 100%;
}

td, th {
font-size: 60%
}
<style>
</head>
<body>

All your normal output in here

</body>
</html>
[/html]

Setting body text size to 100% is just a trick to get all browsers to act in a more similar manor.

You can find out all you need to about CSS at www.w3schools.com

I also notice that in your html you open the font tag then the table tag but then you close the font tag before closing the table tag. This is bad form, tags should be nested with crossing them over like that.

You can get your HTML checked by using the validator provided by W3C located at

http://validator.w3.org
Mar 30 '06 #2
mart2006
12 New Member
You are a life saver! Thanks a million!
Mar 30 '06 #3
mart2006
12 New Member
One more quick question. I'm having a similar problem with setting table width and height, can I enter these properties in the same css file and if so how?

Thanks again, very much appreciated.
Mar 31 '06 #4
Banfa
9,065 Recognized Expert Moderator Expert
Certainly

[html]
<style>
table {
width: 720px;
height: 180px;
}
</style>
[/html]

That sets the height and width in pixels, you can also use
  • em - (related to current text height 1 em = 1 x current text height
  • mm cm pt - centimeters, millimeters or points sets a absolute size but don't because you don't know the size of everyones monitor
  • % - table size in relation to it's containing element as a precentage, however % heights don't always act in a manor that is useful

This will change the size of all tables on you page to change the height of a single table do this

[html]
...
<style>
#OutputTable {
width: 720px;
height: 180px;
}
</style>
...
<table id="OutputTable ">
<!-- This table sized -->
</table>

<table>
<!-- This table NOT sized -->
</table>
[/html]

to change the size of 2 or more tables but not all of them

[html]
...
<style>
.outputTable {
width: 720px;
height: 180px;
}
</style>
...
<table class="outputTa ble">
<!-- This table sized -->
</table>

<table class="outputTa ble">
<!-- This table sized -->
</table>

<table>
<!-- This table NOT sized -->
</table>
[/html]


That is every id on a page must be unique, however classes can be used multiple times.
Mar 31 '06 #5
mart2006
12 New Member
Thanks for the prompt response. I've tried entering the table attribute code in my css file but it seems to make little difference.

Here is my include:

[HTML]
<HTML>
<HEAD>
<TITLE>Displa y Calls</TITLE>
<link href="main.css" rel="stylesheet " type="text/css">
</HEAD>
<BODY>
[/HTML]

Here is my css file

[HTML]
<style>
body {
font-size: 50%;
font-family: arial;
}

td, th {
font-size: 75%;
font-family: arial;
}

a:link{
color:#000040;
text-decoration: none;
}
a:visited{
color:#000040;
text-decoration: none;
}
a:hover{
color:#000040;
text-decoration: underline;
}
a:active{
color:#000040;
text-decoration: none;
}
table {
width: 72px;
height: 180px;
}
</style>
[/HTML]

And finally the start of my table (the rest if it is simply inserting php variables into the table cells.

[HTML]
echo "
<table border=1>
<TR>
<TH>Call ID</TH>
<TH>Techncian </TH>
<TH>User</TH>
<TH>Call Description</TH>
<TH>Call Category</TH>
<TH>Call Priority</TH>
<TH>Call Resolution</TH>
<TH>Time Taken in hours</TH>
<TH>Time Taken in minutes</TH>
<TH>Date Logged</TH>
</TR>";
[/HTML]

Any idea why this is not taking effect?
Mar 31 '06 #6
Banfa
9,065 Recognized Expert Moderator Expert
Not

.table

but

table
Mar 31 '06 #7
mart2006
12 New Member
Sorry that is something I added after in an attempt to make it work (thought Id come across it somewhere) but it clearly didnt have any effect!
Mar 31 '06 #8
Banfa
9,065 Recognized Expert Moderator Expert
You don't appear to be echoing

</table>

or is that just a posting omission
Mar 31 '06 #9
mart2006
12 New Member
Yep that is just an omission.

Perhaps I should explain that the reason I want to do this is that when I enter data dynamically into the table, the table is being automatically stretched out meaning the user has to scroll from left to right in order to read the contents. Instead I want the table to stay at a fixed width but increase in height to enable all of the contents to be entered.

Hope this makes sense?!
Mar 31 '06 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
6652
by: Cengiz Ulku | last post by:
Hi all, I know now how to change the font name of a RTF file in a RTB control using, for example: RTextBox1.SelFontName = cmbFonts.Text I have a RTF file -created with Word- displayed in a RTB control. Whenever I change the font type during the runtime by selecting a font name from a combobox -of all system fonts, the text changes its font correctly but I loose some formatting such as a bold text and/or titles become normal text.
55
5033
by: Haines Brown | last post by:
I've been setting font-size 1em; as the default in my style sheets. Until now, that seemed to be ok. But now I'm beginning to wonder. My aim is to have an easily readable, but not overly large text when the user uses the default font size in his browser and uses the typical display resolution. I did a reinstall of my friendly browser in a different environment, and I am surprised to find that its default for serif is Times 16 and
115
7270
by: J | last post by:
I've run CSSCheck on my style sheets and I always get a warning similar to this: "font: bold 9pt/100% sans-serif Warning: Absolute length units should not generally be used on the Web ..." Yet if I use 'x-small' instead of 9pt, I get bigger type on IE6 and smaller type on Mozilla. My choices seem to be:
8
2436
by: François de Dardel | last post by:
I have a complete Intranet site with about 140 pages using Verdana as the basic font. How do I place a table (12 columns) with Arial instead of Verdana, only for that table. I have defined a style in my CSS and tried to apply it to the table, doesn't work. I have tried to wrap the table in a div with the style. Doesn't work. I have tried the old-fashioned <font> tag, doesn't work. I must be doing something wrong. It works however if I...
98
6323
by: Pamel | last post by:
I know this must have been asked elsewhere, but I cannot find it. There is a piece of text on my web page that I don't want browsers to resize. IE won't resize it if I specify the size in px, but everything else will. Is there any way to prevent browsers from resizing text? If you could just point me to where this has already been answered, that would be great. Paul
15
2660
by: chart43 | last post by:
> I work on Windows (unfortunately). But I regularly view my work in a Mac > (IE5.x and Safari). I do not notice the phenomenon that you describe. > But then, it hardly seems relevant. What's important is that 100% is > right for you on your setup, and right for someone else on their setup, > whatever there os is. > >> normal in my case results in too big on Windows. My code is all >> valid, so too are style sheets. > > I doubt you have...
0
2951
by: Paul D. Sullivan | last post by:
I've been trying to find out how to increase the font size in the text entry fields in Invision Power Board 1.3 for a while. The part where you enter your post and do the quick reply and all that has a really small font by comparision to the display font in the forum, and I wanted to at least have the same size if possible. After some hours of working the issue, I tested about every relevant entry in the Style Sheet. I found one line...
60
4817
by: deko | last post by:
As I understand it, most browser manufacturers have agreed on 16px for their default font size. So, this should be an accurate conversion for percentages: px % 16 = 100 14 = 87.5 13 = 81.25
1
6782
by: Randy Shore | last post by:
I have run into a problem with the new rich text control in Access 2007. It seems that you can only choose from 6 preset font sizes when entering or editing text. The sizes are 8,10,12,14,18,24,36, which as I understand it, corresponds to Font Size=1 through Font Size = 6 in HTML. Is there any way around this. I have a need to display the data at 46pt, and also to make fine discriminations in font size depending on the data displayed. ...
2
1077
praCash
by: praCash | last post by:
Hi guys, I have done a ppllication. for Cotnent management system. in it i have designed my content. but after creating content for every page i desided to increase the font sizes. as the previously designed pages are more I cannot wast my time while updating(Changing) each and every page. i need some other solution instead of updating every page. just like a short cut.
0
9903
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11041
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10692
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10373
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5753
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5946
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4167
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.