[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

Forwarding a link...

Hi,

I'm writing a page in PHP that does a search in a DB and displays 10 results by page.

I'm using the POST method to pass through the URL the number of the page to display.

My only problem is that I want to have access to the number of page in the URL, so I create a page
that takes the number of page and forwards to the results.

To forward the page, I'm using a basic Javascript like this one :

?>
<script language="JavaScript"><!--
setTimeout("top.location.href = 'Result.php'",2000);
//--></script>
<?php

The thing is that I'd like to pass parameters to the page that is forwarding.

?>
<script language="JavaScript"><!--
setTimeout("top.location.href = 'Result.php?sql=$SQL'",2000);
//--></script>
<?php

This syntax isn't working only because it Javascript.

Anyone knows how it could be done ??

Thanks

JohnnyQ

(BTW, sorry for my bad english !! :D)
0
JohnnyQ
Asked:
JohnnyQ
1 Solution
 
VGRCommented:
say it again JohnnyB (good?) :D

didn't understand anything.

first of all it's GET method that puts anything in the URL

then I also have a lot of FORMs searching a DB and displaying N results/page, and I don't catch your problem 8-)
0
 
tirdunCommented:
I ... think I'm getting this. You want to include a PHP variable in a bit of Javascript (?)

If so, you need to have the php code WRITE the javascript code instead of passing it directly:

so:
?>
<script language="JavaScript"><!--
setTimeout("top.location.href = 'Result.php?sql=$SQL'",2000);
//--></script>
<?php

becomes:

<?
print "<script language=\"JavaScript\"><!--\n';
print "setTimeout(\"top.location.href = 'Result.php?sql=$SQL'\",2000);\n";
print "//--></script>";



0
 
VGRCommented:
yes
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
kimchengCommented:
you could just use

<script language="JavaScript"><!--
setTimeout("top.location.href = 'Result.php?sql=<?=$SQL;?>'",2000);
//--></script>

so php will print the value of $SQL instead of the letter.
0
 
cirtapCommented:
Hi JohnnyQ,

kim's example may already do it, but just in case:
don't get confused with POST and GET commands.
As VGR wrote: it's GET method that puts anything in the URL

You may certainly *POST* a <FORM> but you'll always *GET* a page when using "location.href", so the forwarding-thing you talk about will have your SQL variable in the $_GET array.

CirTap
0
 
VGRCommented:
listening... how far building the script have you, JohnnyQ...
0
 
JohnnyQAuthor Commented:
Thanks for all your answers !!!

It help me very much !!

Thanks again !!

JohnnyQ
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now