Skip to main content
April 23, 2006
Question

Passing PHP form variable to XSLT fragment on dynamic page (PHP)...

  • April 23, 2006
  • 1 reply
  • 410 views
Hello,

Perhaps someone could enlighten me, I am trying to achieve the following...

1. (search.php) User submits keyword in text box and presses submit - keyword is passed to the dynamic page (rssxml.php) containing the fragrment.

2. (rssxml.php) This dynamic page uses the passed keyword to MODIFY the XML URI so as to return posts / items that contain the keyword.

Please see code attached below (I have inserted the word MODIFY to show the part of the XML URI I would like to modify...)

In the setXML, I would like to keep (" http://www.digg.com/rss_search?search=") hardcoded, yet have the ability to insert data (i.e. a keyword) passed from the previous form. Here are some example so you can see what I mean...

http://www.digg.com/rss_search?search=apple
http://www.digg.com/rss_search?search=google
http://www.digg.com/rss_search?search=sgi

Any help will be much appreciated, this is driving me insane. I know exactly what I what to achieve, but am much more of a visual person. Not knowiing the correct code / syntax or whether this can be done at all is driving me insane!

Kind Regards

Craig Hughes
(magikred)
-
This topic has been closed for replies.

1 reply

Inspiring
April 23, 2006
On 23 Apr 2006 in macromedia.dreamweaver.appdev, magikred wrote:

> Please see code attached below (I have inserted the word MODIFY to
> show the part of the XML URI I would like to modify...)
>
> In the setXML, I would like to keep
> (" http://www.digg.com/rss_search?search=") hardcoded, yet have the
> ability to insert data (i.e. a keyword) passed from the previous
> form. Here are some example so you can see what I mean...
>
> http://www.digg.com/rss_search?search=apple
> http://www.digg.com/rss_search?search=google
> http://www.digg.com/rss_search?search=sgi
>
> Any help will be much appreciated, this is driving me insane. I know
> exactly what I what to achieve, but am much more of a visual person.
> Not knowiing the correct code / syntax or whether this can be done
> at all is driving me insane!
>
> Kind Regards
>
> Craig Hughes
> (magikred)
> -
>
> <p>You searched for: <?php echo $_GET['tag']; ?></p>
> <p> 
> <?php
> $mm_xsl = new MM_XSLTransform();
> $mm_xsl->setXML(" http://www.digg.com/rss_search?search=MODIFY");
> $mm_xsl->setXSL("feed-test.xsl");
> echo $mm_xsl->Transform();
> ?></p>

Why not build the string first, then do the transform, thus:

<?php
$mm_xsl = new MM_XSLTransform();
$searchstring = ' http://www.digg.com/rss_search?search=';
$engine = whatever(); /* logic to determine engine goes here */
$searchstring .= $engine;
$mm_xsl->setXML($searchstring);
$mm_xsl->setXSL("feed-test.xsl");
echo $mm_xsl->Transform();
?></p>

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php