Linking PHP pages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
debayan
Forum Newbie
Posts: 3
Joined: Wed Jan 18, 2006 3:30 pm

Linking PHP pages

Post by debayan »

Can i link the same php page in that page?
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

yes.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

(as long as you don't mind the universe imploding)


but in all seriousness the only thing you have to worry about is a page un-conditionally using include() on itself (causing an infinite loop)
User avatar
cj5
Forum Commoner
Posts: 60
Joined: Tue Jan 17, 2006 3:38 pm
Location: Long Island, NY, USA

WTF?

Post by cj5 »

Are you talking about this?

Code: Select all

<a href="<?php echo $_SERVER['PHP_SELF']; ?>">Link</a>
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

no..something like this:

page1.php:

Code: Select all

<?php
include("page2.php");
?>
page2.php:

Code: Select all

<?php
include("page1.php");
?>
What you suggested will just reload the same page over again.
User avatar
cj5
Forum Commoner
Posts: 60
Joined: Tue Jan 17, 2006 3:38 pm
Location: Long Island, NY, USA

Yes sir

Post by cj5 »

Code: Select all

<?php

$page = 1;
$include_page = 2;

if($page == 1) {
    include("page" . $include_page . ".php");

    $page = 2;
    $include_page = 1;
} elseif($page == 2) {
    include("page" . $include_page . ".php");

    $page = 1;
    $include_page = 2;
}

?>
This maybe?
debayan
Forum Newbie
Posts: 3
Joined: Wed Jan 18, 2006 3:30 pm

Centers.php

Post by debayan »

hawleyjr | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I tried by using the following code snippet: Basically have to increment $id and $sid by 10 and reload the page again and call somefunction($id, $sid) with the new values.

Code: Select all

if(isset($_GET('id'))==false and isset($_GET('sid'))==false)
{
     $id=1;
     $sid=10;
}
	
	
else
{
    $id=$_GET('id');
    $sid=$_GET('sid');
}

somefunction($id, $sid);

?>

<form action="/jacid/Centers.php" method="get">
Enter next start id:
<input type="int" name="id"><br>
Enter next stop id:
<input type="int" name="sid"><br>
<input type="submit" name="submit" value="NEXT SET">
</form>
<?
This is not working. Can you suggest why.


hawleyjr | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Where is the "somefunction()" function?
debayan
Forum Newbie
Posts: 3
Joined: Wed Jan 18, 2006 3:30 pm

Centers.php

Post by debayan »

hawleyjr | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


somefunction($id, $sid) is there in my code. I didn't include it here.

Code: Select all

function somefunction($id, $sid)
	{
	set_time_limit(0);
	mysql_select_db("jn5001");
	$address=mysql_query("select address from document WHERE address!='' and id between '$id' and '$sid'");
	while($eachaddr=mysql_fetch_row($address))
	{
	  foreach($eachaddr as $line)
	    {
		 if($line==" ")
		   break;
		 else   
	     address($line);
		}
	}
	
	}
hawleyjr | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Code: Select all

i
if(!isset($_GET['id']) && !isset($_GET['sid']) )
{
$id=1;
$sid=10;
}
Try this.

BTW Please use the php bbcode tags when posting code.

Thanks
Post Reply