Help ASCII Table

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

Feeling bored with myself in the holidays (which happens quite often) I decided to take the "next step" forward and learn XHTML - Strict (because I am fairly confident I know XHTML Transitional) and with it CSS and PHP.

I set to work on a question that I get asked frequently, and that is

Friend: "What is the number for the character with ?"
Me: "I'm not too sure hang on"
[goes off to where abouts unknown to find the character]
Me: "The number is "
Friend: "Oh ok cool"
[me thinking to my self 'a think you would be me']

Anyway, I decided to make a webpage showing all the ASCII codes and number combinations.

The page can be found here:
http://chengeu.krayup.com/testing/charsinphp.php

Now the problem I having are those blank cells, how can I make it(using PHP coding not CSS) so that if there is no character or is blank it will output a  ?

Another problem I am also having is that in XHTML - Strict you can't put ... How do I get around that without doing ... ?

Any other comments regarding my CSS,PHP , (X)HTMl coding are also appreciated.
I am not putting a doctype up yet so that I can choose what I want to valid date it as (XHTML - Strict).

And also, I put the PHP loop in a function cause I want to learn how to use functions.

The source code can be found here:
http://chengeu.krayup.com/testing/charsinphp.phps

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

I've always used this site: http://www.jimprice.com/jim-asc.htm
It has both the IBM extended ACII chart and the Microsoft Windows extended ASCII chart.

(Will someone please tell me why Microsoft feels the need to tamper with predefined standards? Roll eyes )

Mark Hensler
If there is no answer on Google, then there is no question.

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

Cool thanks Mark, I've added it to my bookmarks list. Laughing out loud

However I would still like to make that table :S

They have: 447 posts

Joined: Oct 1999

as far as the blank cells, just put an   on either side of the value

for instance
<td>&amp;nbsp;&amp;#009;&amp;nbsp;</td>'

it'll still be centered and the cells will show up.

Busy's picture

He has: 6,151 posts

Joined: May 2001

I have a table of characters on my site, can be found here

you could always use &nbsp; as a default for every cell, so empty ones just have the default space.

Tables are valid XHTML Strict but are perfered to be used for data content, not layout, even thou you can get around it (isn't XHTML fun). the only real way to align the table is within the div tag but you can align the contents with either CSS (text-align:?) or TH (default is bold and centered) - i think th is valid

just remember to keep everything lower case with php and use &amp; for &

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

The whole table is generated with a few lines of PHP coding but I would like to know how to change the cells which have nothing to having a &nbsp;

Quote:
you could always use &nbsp; as a default for every cell, so empty ones just have the default space.

How would I do that?

dk01's picture

He has: 516 posts

Joined: Mar 2002

Just so you know that although they may display nothing some results of the chr() function are tabs, carriage returns, etc: http://www.php.net/manual/en/function.chr.php

As far as making the default in cells goes it is not an attribute or anything. Just have it in every cell. So change this:

<?php
echo \"<tr><td><p class=\\"center\\">\" . $i . \"</p></td><td width=\\"100\\"><p class=\\"center\\">\" .  $character . \"</p></td></tr>\n\";
?>

to this:
<?php
echo \"<tr><td><p class=\\"center\\">&nbsp;\" . $i . \"</p></td><td width=\\"100\\"><p class=\\"center\\">\" .  $character . \"</p></td></tr>\n\";
?>

This is what rob suggested.
-dk

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

Oh ok cool, Thanks Laughing out loud

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.