Jump to content

request send to server a, result on server b


adistan

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
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.