Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display values of the form inside the table on the new page

Status
Not open for further replies.

sharapov

MIS
May 28, 2002
106
US
I am generating data from database and displaying it inside input text boxes (for users to make some changes). What I need to do is when user presses "submit" button display all of the results inside the table on the new opened page. How can I do it?

Here is the example of what I am trying to do without actual data and php:
 
Well, those textboxes need to be inside a form, along with the submit button.

Then, on the new opened page (the action of the form), you will be able to access those variables either in the $_POST or the $_GET array, depending on the method of the form.

Just to see where you stand, make the new page nice'n simple and do this
Code:
print &quot;<pre>&quot;;
print_r ($_POST);
print &quot;<HR>&quot;;
print_r ($_GET);

From there you should be good.

-Rob
 
Well,

Text boxes are inside form already. Submit bution on the other hand doesn't have to be, because I can do onclick=&quot;document.form_name.submit()&quot;

I know that you can read the values of the submited form with the $_POST or $_GET, but how can I:

1. Open a new page with just a &quot;menu bar&quot; on it , (I guess I can open new page if I set target=&quot;_blank&quot;, but how can I open it with just &quot;menu bar&quot; showing on the page)

2. How can I loop through the results from $_POST to insert them inside the table.

Thanks.
 
1st part is javascript

2nd part is
Code:
foreach ($_POST as $key=>$value) {
  echo $key.&quot;  &quot;.$value.&quot;<br>&quot;;
}

As to the javascript part, the only way I've accomplished this is using a button to call a javascript function which opens a new window using the
window.open(...) command, then using php or javascript to populate the URL with the proper $_GET variables.

the easiest way to achieve this would be to make your form submit via post to a helper page. This helper page writes the javascript, part of which is a foreach loop as above, which populates all the get variables... i.e. my loop above would change to

$query_string = &quot;?&quot;;
foreach ($_POST as $key=>$value) {
$query_string.=&quot;$key=$value&&quot;;
}

I odn't think this is the best way, but it's the easiest.

G'luck!

-Rob
 
skiflyer,

Thank you for your reply, but I seem to be confused a liitle bit on how you are trying to accoplish what I asked for.

First of all after I get all the values from $_POST how do I loop it to insert them in the table.

Second, how can I &quot;using php or javascript to populate the URL with the proper $_GET variables&quot;

And what is the &quot;helper page&quot;?

Finally, can you mix POST and GET together? I thought it's one or the other.

I'd really appreciate if you would post a more complete sample of the code.

Thanks.
 
to put them in a table:

1) write the opening tags to the browser (<table><tr> etc)
2) write each variable between <td> and </td> tags

if you want to have a certain number of columns then use a variable to count the number you have outputted and when you get to how many you need, output </tr><tr>. Remember to output </table> at the end.
 
KempCGDR,

Thank you for your reply, but you still haven't answer my question. How can I loop to get the values into the table! I know how table structured. But what I don't know is how to take all of the values from $_POST and put them into the table!
 
skiflyer already told you that further up, he gave you the code to get each variable, the rest should be relatively easy to put together.
 
Yes, you can mix post and get together.

You indicated you wanted things to happen in a pop up rather than in the main page, hence the idea of using javascript and a helper page. I'd advise getting it working normally first.

So, make a normal form... then do just as Kemp suggested... here's about as complete an example as I have time for this week... (excuse my typos, I'm in vbscript mode right now)

Code:
echo &quot;<table>\n&quot;;
$columns = 3;
$cur_column = 0;
foreach ($_POST as $key=>value) {
  if ($cur_column == 0) {
    echo &quot;<tr>\n&quot;;
  }
  if ($cur_column < $columns) {
   echo &quot;<td><b>$key:</b>$value</td>\n&quot;;
   ++$cur_column;
  }
  if ($cur_column == $columns) {
    echo &quot;</tr>\n&quot;; 
    $cur_column = 0;
  }
}

not the neatest code ever... but I'm pretty sure it's functional
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top