adistan Posted July 16, 2006 Share Posted July 16, 2006 hiI 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 Quote Link to comment Share on other sites More sharing options...
Barand Posted July 16, 2006 Share Posted July 16, 2006 Here's how I did a similar thing recently.On server A have you script which searches the db and echos the results as XMLSample 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] Quote Link to comment Share on other sites More sharing options...
adistan Posted July 16, 2006 Author Share Posted July 16, 2006 10x, I also thinking this is a good metod (xml) :)I will try it!:)Another ideea?:)) Quote Link to comment Share on other sites More sharing options...
ShogunWarrior Posted July 16, 2006 Share Posted July 16, 2006 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.