Jump to content

[SOLVED] A small problem with variables, help please :)


Recommended Posts

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 :)

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>

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.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.