Load include PHP from an External ID

Asked

Viewed 163 times

1

You guys, good night!

I have the following Code:

        <!-- Box do Cupom -->
        <article class="box_cupom">
            <?php include("cupom.php"); ?>
        </article>

This include PHP carries an external page that contains some information from a "Non Tax Coupon". I would like that page to be loaded from an ID of a Div from within include. Exelmpo:

        <!-- Box do Cupom -->
        <article class="box_cupom">
            <?php include("cupom.php#ID"); ?>
        </article>

However, when I write this way PHP returns me the following error:

Warning: include(coupon.php#initialstart): failed to open stream: No such file or directory in ...

Is there any way to do this in PHP so you don’t need to use HTML Frames?

  • 1

    What is the coupon code.php?

  • 1

    include won’t work like this because it looks for the file name, and since there isn’t a file called coupon.php#somedQualquer, it will never load. I understood that you want to inject the content of coupon.php on the page in question, but what is the idea of using the ID? Could you make it clearer?

  • 1

    You want after include the page to be directed to a specific div ? It’s a bit confusing

  • 1

    @elvex include, in php, accepts querystring?

  • 1

    As far as I know, no. You should pass the correct file name. But as @Pedroaugusto said, it’s a bit confusing, what is your goal?

  • 1

    Dear Jefferson, include does not understand HTML, and also does not understand querystrings, INCLUDE is part of PHP, which is a language processed in the back end and can return anything, html, txt, jpeg, depends on what you want to send as "HTTP response". include serves to join 2 files and process them as if they were a single PHP script, of course it has behavior variations, like include support return, but to summarize, include only includes one HTML in another in your script, because the including output was written as HTML.

Show 1 more comment

2 answers

-1

the include file would be a kind of TAX COUPON, however I didn’t want it to get the header because it is big (height), I wanted the include file to always load after a DIV with such an ID, thus showing the "shopping list" and leaving the header above.

Class CSS "boxcupom" has 300px width and 450px height; and overflow scroll.

So as the Coupon has more item, it increases... But as I said above, I didn’t want you to get the Header....

HELP

  • Do the "full" include, hide what you don’t want with css

-1

You could do using the GET method, for example if you want to pick up by ID 22 you can use this solution.

    <!-- Box do Cupom -->
    <article class="box_cupom">
        <?php include("cupom.php?id=22"); ?>
    </article>

and on the php coupon you can get the id by:

<?php
    $id = $_GET["id"];
?>
  • I do not understand why you have denied the question, when you say what you expect and why it is not a valid solution. .

Browser other questions tagged

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