Jump to content

Archived

This topic is now archived and is closed to further replies.

karthikeyan_coder

include... not wroking with ?id get method

Recommended Posts

banner.php
is a file which outputs a banner image...
if we call banner.php?59 then it will show 59th banner...

i want to show banners in index.php

i have this variable $banner_file = "banner.php?59";

if i include($banner.php?59); then it is giving an error...

i tried $banner_file = "'"."banner.php?id=".$arr."'";
echo("$banner_file");

output is.. 'banner.php?id=12'

still im getting faild to ourput stream...error... please help me

Share this post


Link to post
Share on other sites
You cant include the file like that, if you want to send the parameters you can set it before including the file, so when it loads the banner file it will have the id you set it before.

[code]
$id = 12;
$banner_file = "banner.php";
include $banner_file;
[/code]

Another thing you can do its to send the parameters in the main file (where your include the banner file) like this:

index.php?id=12
[code]
$banner_file = "banner.php";
include $banner_file;
[/code]

So in the banner file you can get the $_GET["id"] value.

Share this post


Link to post
Share on other sites
im not cleard with you... you said i can set it before including file... $id = 12; where you are connecting the $id with $banner_file ??? please clear my doubt.. any other better solution?

Share this post


Link to post
Share on other sites
technically no, you can put an include anywhere.  If there is data above it, it's passed into the include.  An include isnothing but a reference.  The php engine looks at the include statement, finds the file it's pointing to, and just puts it straight into the page. That's it, if you set a variable before the include, and in the include try to reference it, it works just the same.

Share this post


Link to post
Share on other sites

×

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.