MsRedImp Posted October 26, 2007 Share Posted October 26, 2007 I am trying to echo a variable inside a table because I am trying to create a football prediction league and don't want to have to type out all of the fixtures and team names and I need to know what prediction each person entered for which team so I have tried stringing this to a post page. I have tried numerous of things to get it to print the string variable for the team name, but nothing works. Here is my current first page: <link rel="teams.css" type="text/css" /> <style type="text/css"> input{ text-align:center; } </style> </head> <body> <form action="post2.php" method="post"> <div style="position:absolute; top:195px; left:470px"><input type="submit" value="Enter"/></div> </form> <div style="position:absolute; top:143px; left:371px; text-align:center; width: 256px; height: 31px;"> <table width="250" border="0"> <tr> <td width="80"> <style type="text/css"> echo "$team1"; </style> <style type="text/css"> echo {$team1}; </style> <?php echo "$team1"?> </td> <td width="76"><input name="selection" type="text" size="1" maxlength="1"/><input name="selection1" type="text" size="1" maxlength="1"/></td> <td width="80">England</td> </tr> </table> 1) I have related the link to a css page that contains the variable: $team1 = "Germany" 2) I have tried using a <style ="text/css"> etc, to pull the variable from the css form and echo the team name, which should say "Germany", but this doesn't work. I then did this again with different code (It may be incorrect because I am new to coding). 3) I then used a php script <?php echo variable?> etc, to see if that would echo the variable. This is most likely wrong, and I don't know where to store the variable for php to pull it. This obviously didn't work. Here is the link to my page: http://msredimp.110mb.com/post.php Thank you for any help Quote Link to comment https://forums.phpfreaks.com/topic/74904-solved-a-small-problem-with-variables-help-please/ Share on other sites More sharing options...
premiso Posted October 26, 2007 Share Posted October 26, 2007 Your not working within <?php <?php $team1 = "Germany"; ?> <link rel="teams.css" type="text/css" /> <style type="text/css"> input{ text-align:center; } </style> </head> <body> <form action="post2.php" method="post"> <div style="position:absolute; top:195px; left:470px"><input type="submit" value="Enter"/></div> </form> <div style="position:absolute; top:143px; left:371px; text-align:center; width: 256px; height: 31px;"> <table width="250" border="0"> <tr> <td width="80"> <style type="text/css"> <?php echo "$team1"; ?> </style> <style type="text/css"> <?php echo $team1;?> </style> <?php echo "$team1"?> </td> <td width="76"><input name="selection" type="text" size="1" maxlength="1"/><input name="selection1" type="text" size="1" maxlength="1"/></td> <td width="80">England</td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/74904-solved-a-small-problem-with-variables-help-please/#findComment-378711 Share on other sites More sharing options...
MsRedImp Posted October 26, 2007 Author Share Posted October 26, 2007 Hmm I opened a PHP new in dreamweaver so it should be PHP, I used those tags you added but they didn't work. What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/74904-solved-a-small-problem-with-variables-help-please/#findComment-378756 Share on other sites More sharing options...
MsRedImp Posted October 26, 2007 Author Share Posted October 26, 2007 Bah...so stuck, can anyone help? =/ Quote Link to comment https://forums.phpfreaks.com/topic/74904-solved-a-small-problem-with-variables-help-please/#findComment-378761 Share on other sites More sharing options...
toplay Posted October 26, 2007 Share Posted October 26, 2007 Bumping your own post after only 20 minutes is not good. When posting it's best to be detailed and stating things like "didn't work" does not give enough information to forum members to help you. Post your latest relevant code in the forum and enclose them in code tags. Where is $team1 getting assigned a value? How are you grabbing the data submitted from the form? i.e. <?php $selection = isset($_POST['selection']) ? $_POST['selection'] : ''; $selection1 = isset($_POST['selection1']) ? $_POST['selection1'] : ''; ?> You can't use $selection and $selection1 directly without having register_globals on, which should not be on for for various reasons. Use $_POST (or $_REQUEST) as demonstrated. Tell members what is currently going wrong every step of the way. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/74904-solved-a-small-problem-with-variables-help-please/#findComment-378766 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.