Jump to content


request send to server a, result on server b

  • Please log in to reply
3 replies to this topic

#1 adistan

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 16 July 2006 - 09:16 AM


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 :)


#2 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,020 posts

Posted 16 July 2006 - 01:36 PM

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)

  // 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>
	echo $item;
echo  "</fads>\n</rss>";

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

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 adistan

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 16 July 2006 - 02:01 PM

10x, I also thinking this is a good metod (xml) :)

I will try it!:)

Another ideea?:))

#4 ShogunWarrior

  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 16 July 2006 - 03:37 PM

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.
<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users