I am working on this code for php with HTML now i want a container around the information but it is not turning out. Can someone help me understand what I am doing wrong. Should my HTML code suppose to be at the top of the page or not. Here is my code..

<?php
function getContent($page) {
  echo "<table width=\"100%\" border=\"0\" cell padding=\"2\" cellspacing=\"\" }\n";
  Switch($page){

   case "about";
   	echo "<tr style=\"background-color:#FFFF66\">\n";
   	echo "  <td align=\"center\"> A little about me...</td>\n";
   	echo "</tr>\n";
   	echo "<tr>\n";
   	echo "<td>Age 26<br>\n";
   	echo "     Gender Female<br>\n";
   	echo "     Bio: I am 26 years old. I am a mother of twin girls who are 9 years old. I been with my husband for 11 years,
   	           but been married for 5 years. I enjoy learning and working on computers. I love to play video games on
   	           the PC. I am going to Stark State College for COmputer Programming and Database Mangament. After I get
   	           done with this degree I am going back for Web Design that should take about a year since half my classes
   	           are of web design now.\n";
   	echo "</td>";
   	echo"</tr>";
   	break;
  case "goals":
   	echo "<tr style=\"background-color:#FFFF66\">\n";
   	echo "  <td align=\"center\"><b>My goals</b></td>\n";
   	echo "</tr>\n";
   	echo "<tr>\n";
   	echo "  <td> My goals are to provide for my family after I get out of college.
   		     I want my kids to grow up happy and enjoy their life. I also want
   		     to move to a better neighborhood for my kids.</td>\n";
   	echo "</tr>\n";
 break;
 echo " <div id=\"container\">\n";
     default:
       echo "<tr style=\"background-color:#FFFF66\">\n";
       echo "  <td align=\"center\"><div><b> Welcome to my page,please choose and interest that you will like.</td>\n";
       echo " </tr>\n";
       break;
   }
   echo "<tr>\n";
   echo "  <td align=\"center\">";
   echo "<a href=\"querystringexample.php\">Home</a>";
   echo " <br>";
   echo "<a href=\"querystringexample.php?page=about\">About me</a>";
   echo " <br> ";
   echo "<a href=\"querystringexample.php?page=goals\">My goals</a>";
   echo " </td>\n";
   echo "</tr>\n";
   echo "</table>\n";
 }
echo "</div>\n";
echo "<html>\n";
echo "<head>\n";
echo " <title>About Me</title>\n";
echo " <style type=\"text/css\">\n";
echo "		body { \n";
echo "					background-color:#E969AB;\n";
echo "					color:#000;\n";
echo "					font-size:125%;\n";
echo "					font-family:Georgia,Verdana,sans-serif;\n";
echo "				}\n";
echo "     #container{ \n";
echo " 						background:#FFF;\n";
echo " 						width:550px;\n";
echo " 						margin:auto;\n";
echo " 						padding:5px 10px 2px 10px;\n";
echo " 						border:5px double #050833;\n";
echo " 		}\n";


echo "    </style>\n";

 echo "</head>\n";
 echo "<body>";
 getContent($HTTP_GET_VARS['page']);
 echo " </body>\n";
 echo "</html>\n";

Recommended Answers

All 4 Replies

The code is clumsy. Why dont you seperate html and php?
why are you taking a "</div>" at line number 49?
You are rendering a table by calling the function getContent() from line no 73, right?
Its O.K. only. There is no restriction that you should maintain any order for php functions. Read about how PHP scripts interprets at the runtime and it will be clear to you. What is your error?
Why are you using $HTTP_GET_VARs?Use $_GET instead. Http_get_vars is deprecated.

The problem is Switch . All PHP functions use lower case, and are case sensitive so use switch instead.

Also the echo on line 31 is invalid, because it is after a break .

The table tag on line 3 is closed incorrectly with } instead of >

Member Avatar for diafol

Eek! There must be a better way to do this. Even using include files would be an improvement.

include("includes/{$page}.htm");

Just create small files with your html. $page will load the right one (if it's got the same name).

Im not getting any error i just cant get the box to go around the wording like it is suppose to do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.