How do you get a function to display in a table?

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
canadian_angel
Forum Commoner
Posts: 31
Joined: Fri Jun 11, 2010 3:13 pm

How do you get a function to display in a table?

Post by canadian_angel »

I am so confused I have to get this function to display in a table and I really dont know how, I have tryed this so many times and just dont get it. HELP!



<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Teas of the World!</title>
</head>
<body>
<?php // Script 10.6 - Teas of the World.php
// This function displays a four cell table.
function tea($types) {

$types = array ("Chinese Green", "Japanese Red", "Korean Black", "British White");

echo "<table border=1 cellpadding=1 cellspacing=1><tr>";
for ($cell = 0; $cell < 4; $cell++) { // Displays the cell count.
echo "<td>".$types[$cell]."</td>";
}

}

"</tr></table>";
?>
</body>
</html>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How do you get a function to display in a table?

Post by requinix »

1. The function prints the table.
2. For any function it will execute if and only if you call it.
3. You do not call the function.
Therefore the table will not be printed.
canadian_angel
Forum Commoner
Posts: 31
Joined: Fri Jun 11, 2010 3:13 pm

Re: How do you get a function to display in a table?

Post by canadian_angel »

I have been trying and can't get it to work-any help would be much appreciated!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How do you get a function to display in a table?

Post by requinix »

Code: Select all

tea(null);
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: How do you get a function to display in a table?

Post by JakeJ »

Also,

Your function doesn't actually require any additional information so it could just be: function tea()

and to call it:

Code: Select all

tea()
Post Reply