Jump to content

Archived

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

adistan

request send to server a, result on server b

Recommended Posts

hi

I need help with this problem:

I have ServerA, with some db. I want to put on one page on ServerB a script, what ever, to make this:

I am on Server B. I complete a search field. When I push the button "search", that search request go to server A, server A make search in db, server A return results to Server B, and to page on server B display result.

I have no ideea how to start this, what to search...

thank you in advance :)

adi

Share this post


Link to post
Share on other sites
Here's how I did a similar thing recently.

On server A have you script which searches the db and echos the results as XML
Sample code (scriptA.php)

[code]<?php
  //
  // build search query here
  //
$res = mysql_query($sql_search_query) or die(mysql_error());
$count = 0;

echo  "<?xml version='1.0' encoding='utf-8'?>\n<rss version='0.92'>\n\n<fads>\n";

while (list($id, $title, $price, $cat, $image) = mysql_fetch_row($res)) {
$image_position = ($count++ % 2) ? 'L' : 'R';
$title = urldecode($title);
$price = '$'.number_format($price,0);
 
$item = "<item>
<id>$id</id>
<pos>$image_position</pos>
<category>$cat</category>
<title>$title</title>
<price>$price</price>
<imageurl>$baseDir$image</imageurl>
</item>\n\n";
echo $item;
}
echo  "</fads>\n</rss>";
?>[/code]

Then, on server B, use an xsl stylesheet to format the xml output from scriptA
[code]
    <?php
    $xml = simplexml_load_file('http://www.domainA.com/scriptA.php?param=xxx');
    $xsl = simpleXML_load_file('my_format.xsl');
    $proc = new XsltProcessor();
    $proc->importStylesheet($xsl);
    $newxml = $proc->transformToDoc($xml);
    print $newxml->saveXML();
    ?>
[/code]

Share this post


Link to post
Share on other sites
10x, I also thinking this is a good metod (xml) :)

I will try it!:)

Another ideea?:))

Share this post


Link to post
Share on other sites
I like JSON compared to XML, I really think where public syndication is not the task that it's not neccessary to have all the extra XML tags.
But of course there's so many pros/cons to XML/JSON.

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.