I've been drawing a complete blank on this all day...
I have a php page, hotlist.php, which does a bunch of mysql stuff and generates text based on the results. If I use a browser to view hotlist.php?id=10, I get some simple html and text displayed on the page.

I want to be able to display that information in a section of another page, like a table. I just can't figure out how to call it so that it displays that information instead of just outputting "hotlist.php?id=10".

Does that make sense? I want to call hotlist.php from somewhere in another php page so that hotlist.php displays its information in that place...

Any help is appreciated and if I need to clarify this more, I'd be happy to do so.

    Have you tried a simple

    $id = 10;
    include("hotlist.php");

      Shortly after posting, I started thinking about just storing all of the output in one variable in hotlist.php instead of using echo statements to output it, which is what I think I'm going to do.

      Quick example, hello.php

      <?php
      $message = "Hello, World!";
      ?>
      

      Then the html page would be: index.php

      <?php
      include "hello.php";
      ?>
      <html>
      <body>
      <?php echo $message;?>
      </body>
      </html>
      

      I thought there would be some way to use a php page with echo statements to do the same thing.

      Let's say I have this different hello.php

      <?php
      echo "Hello, world!";
      ?>
      

      I want to be able to display the output of hello.php on another php page (one that has html on it) index.php:

      <html>
      <body>
      //call hello.php to output here
      </body>
      </html>
      

      Anyway, I know a way that I can do this now so its really not an important problem anymore, but I'm still curious if there is a way to do this.

      (edit)Actually, it would be a lot easier for me if it was possible to do this by just calling hotlist.php. That way I can put this on any page with just a simple line, instead of having to add an include statement and having to rearrange my code so that I have an id in the right place each time.

        Have you tried the include? That is the typical way to do these things.

          Maybe I am misunderstanding how you propose to use the include. If I had a .php file with just an echo statement in it, how would I get that output where I want it on my page?

            include ('hello.php');

            or you can do

            readfile ('hello.php');

            but that leads to problems as I have learned 😃

            I'm guessing you are using dreamweaver? The include line does mess everything up, so, use read file first and for the last change, change readfile to include in the code

            or are u trying to dispaly the info with an echo?

              I knew I was just doing something stupid.

              I've really only used "include" for things that I use before any html output, so it just wasn't occuring to me that I can put an include statement anywhere on the page... anyway, problem solved now.

                Write a Reply...