Page 1 of 1

Linking PHP pages

Posted: Wed Jan 18, 2006 3:33 pm
by debayan
Can i link the same php page in that page?

Posted: Wed Jan 18, 2006 6:02 pm
by Jenk
yes.

Posted: Wed Jan 18, 2006 7:09 pm
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)

WTF?

Posted: Wed Jan 18, 2006 7:15 pm
by cj5
Are you talking about this?

Code: Select all

<a href="<?php echo $_SERVER['PHP_SELF']; ?>">Link</a>

Posted: Wed Jan 18, 2006 8:46 pm
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.

Yes sir

Posted: Thu Jan 19, 2006 7:38 am
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?

Centers.php

Posted: Thu Jan 19, 2006 8:37 am
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]

Posted: Thu Jan 19, 2006 8:49 am
by neophyte
Where is the "somefunction()" function?

Centers.php

Posted: Thu Jan 19, 2006 8:58 am
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]

Posted: Thu Jan 19, 2006 9:15 am
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