Query output on another page

Asked

Viewed 369 times

1

I wonder how I can make the result of a query on a page of mine, fill in a tag on another page;

Example:

I have a search page the amount of existing processes, when I click the button, let’s assume it returns me 75 as value.

I want to know, how do I take this 75 (result) and put a pre tag on another page? Thank you

  • What about another page? A popup for example or an open tab like _Blank?

  • Yeah, the result of my query fills a tag from a different page than the one I was on

3 answers

1

Good afternoon!

You could take the amount that was returned "75", pass via GET to another page, create the desired tag and position in HTML with echo, ex:

<?php
   $var = $_GET['valor']; //valor 75
   $tag = "<h2>$var</h2>";
?>
<html>
<head> 

</head>
<body>
   <?php echo $tag ?> <!-- exibindo 75 em h2 -->
</body>
</html>

In this example I used the "75" for display, but I could very well use as id, name, height, etc... Or any other tag attribute.

0

Place the value in a session variable and load the session on the other page, or load the other tab with a query string at the address of the other page.

0

You performed a query in an archive php, create an array and place the contents you want to display on the page, for example:

$data['titulo'] = "Aqui vai o título da página";

Place the contents you want, preferably the array is associative.

Then perform the following:

extract($data, EXTR_PREFIX_ALL, "view");

In which $data is your array, EXTR_PREFIX_ALL is a constant that says that all its variables will have prefixes, and "view" is the prefix that is a String of your choice.

In this case, within your code html, you should write like this:

<p><?php echo $view_titulo; ?></p>

Finally, in your code php, after the command extract you have to call a:

require_once "pagina.html";

That’s how it works with me.

This W3schools link can help: http://www.w3schools.com/php/func_array_extract.asp

Browser other questions tagged

You are not signed in. Login or sign up in order to post.