Jump to content

Does anyone know how to fix this problem? - Read Last Post


j3rmain3

Recommended Posts

I want to display information from several dropdown menus in a table and it would be too time consuming if i was to type in the name i have given to every option. So i have placed this:

echo "<td><p align=center><font face=Verdana size=-1>[b]".$row[filename]tech"[/b]</center></td>";
echo "<td><p align=center><font face=Verdana size=-1>[b]".$row[filename]fin"[/b]</center></td>";
echo "<td><p align=center><font face=Verdana size=-1>[b]".$row[filename]doc"[/b]</center></td>";

The names in the dropdown menu end in either TECH, FIN or DOC.

This is how the data in the dropdown menu has been setup:

<option value=1 name=$row[filename]tech>

This works fine because the name of the option is stored as 'segatech' like it is supposed to. But this only works becasue i have the whole thing within quotes.

I have placed the table like this so the data from the dropdown menu will appear in the cell. But i keep on getting an error which says i cannot have the $row[filename][b]tech[/b] bit.

Is there anyway i can work around this.  ???

Thanks,
J3rmain3
Link to comment
Share on other sites

One more problem im having, i have created a form and a table which i want to display the data in. To move the data from the form to the table, i know that i have to place something like this in at the top:

$variable1 = $_POST['variable1'];
$variable2 = $_POST['variable2'];
$variable3 = $_POST['variable3'];

Is there anyway i can turn this into a loop so that variable4 will appear next without having to do it manually.

Thanks,
J3rmain3.

N.B. I have asked this question 3 times b4 and nobody as helped me so please (thats me pleading) somebody help me.

Link to comment
Share on other sites

yeah your right, he can do that

but look at his keys for POST
$variable1 = $_POST['variable1'];
$variable2 = $_POST['variable2'];
$variable3 = $_POST['variable3'];

they're just the same as the name of the variables he wants
so he'd be just as well off using extract.

I don't know why you don't just use the POST vars themselves, directly

$variabel1 = $_POST['variable1'];
echo $variable1;

Does the same thing as

echo $_POST['variable1'];

nothing really different at all.
Link to comment
Share on other sites

[code]
$num=5; // number of variable(num) to extract
for ($i=1;$i<=$num;$i++) {
    $go="variable".$i;
    $$go=$_POST[$go];
}
[/code]

I have used the coding which MonkeyMat has explained. I looked up extract but did not understand it very well.

I have been able to use the foundations of the coding above and applied it to my table, but i am confused about something. To see if the coding comes out correct i used [b]echo[/b] >>>>> This is how i printed out the coding,

[code]

$x = "$";

echo "$x$go = ${$go}";

[/code]

the output to this is $variable1 =
But the $_POST[variable1] bit doesnt appear. I understand that it will not appear because its a reserved function (or something like that ) but how do i get this to be recognised by the server so that i can send information from the form to the table.

Thanks
J3rmain3
Link to comment
Share on other sites

I am trying to display numbers which have been sent from a form but i get the error message:

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\Apache\Apache2\PHPFiles\brainstorm\btable.php on line 42

This is the code:

while ($row=mysql_fetch_assoc($result)){

$num = $row;
for ($i=1;$i<=$row;$i++) {
$post = $row['filename']."tech";
$$post = $_POST[$post];
}
[b]42:[/b]  echo "<td><font face=Verdana size=-1>".${$post}"</td>";

Can anyone see what is wrong IN LINE 42? Isn't that the way i display something using variable variable

Thanks
J3RMAIN3
Link to comment
Share on other sites

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.