duanoucuo7045 2015-11-13 17:38
浏览 48

如何在PHP中通过搜索返回数据结果的列表

I am getting Terminology wrong or It is quite possible to do?

I am having a PHP page which makes an ebay Api call for seller Profile Search Result, The result is based on the Form Field Input :- Sellername , Country Location etc etc.

I had Kept the HTML content in the PHP with simple HTML FORM and Includes a Class File which takes SellerID as Parameter and return back data embedded into table format of HTML so that return data can be used directly as an HTML to display on webpage using print command.

So far i am able to get data of each individual seller, how can i append my past last 5 seller profile result show ?

As whenever i input the new seller name in search column it refreshes the page which make the data Unusable.

attaching the code of PHP File which create query page and display result.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<?php

include_once 'SellerProfile.php';
include_once 'AppendData.php';

$sellerID='';
$pageResults='';
//$sellerDetail;

if(isset($_POST['SellerID'])){

// DEBUG -----
$debug   = true;
$debug = (boolean) $_POST['Debug'];

// CLEAN SELLER ID -----
$sellerID  = urlencode (utf8_encode($_POST['SellerID']));   // cleanse input
// CLEAN GLOBAL ID -----
$globalID    = urlencode (utf8_encode($_POST['GlobalID']));
// ASOSIATED ARRAY OF SITE ID
$sitearray = array(
    'EBAY-US' => '0',
    'EBAY-ENCA' => '2',
    'EBAY-GB' => '3',
    'EBAY-AU' => '15',
    'EBAY-DE' => '77',
    'EBAY-IN' => '203',
);
// TAKE VALUE FROM ASSOSIATED ARRAY AND SPITOUT ITS VALUE
$siteID = $sitearray[$globalID];


//    $sellerDetail->debug = $debug;
//    $sellerDetail->siteID = $siteID;
$sellerDetail = new \Ebay_Profile\SellerProfile($sellerID,$siteID,$debug);


//$history = '';
//$history = new \Ebay_Profile\AppendData($sellerDetail);

$pageResults = '';
$pageResults .= $sellerDetail;


}
?>


<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>GetUserProfile</title>
<script src="./js/jQuery.js"></script>
<script src="./js/jQueryUI/ui.tablesorter.js"></script>

<!--<script>
$(document).ready(function() {
$("table").tablesorter({
  sortList:[[7,0],[4,0]],    // upon screen load, sort by col 7, 4 ascending   (0)
  debug: false,        // if true, useful to debug Tablesorter issues
  headers: {
    0: { sorter: false },  // col 0 = first = left most column - no sorting
    5: { sorter: false },
    6: { sorter: false },
    7: { sorter: 'text'}   // specify text sorter, otherwise mistakenly    takes shortDate parser
  }
  });
  });
  </script>-->

 </head>

 <body>


 <link rel="stylesheet" href="./css/flora.all.css" type="text/css"     media="screen" title="Flora (Default)">
 <!--
 <form
 action = 'Specifies where to send the form-data when a form is submitted
 method = 'Specifies the HTTP method to use when sending form-data'
 </form>
 -->
<form action="LoadProfile.php" method="post">
<table cellpadding="2" border="0">
    <tr>
        <th>SellerID</th>
        <th>Site</th>
        <th>ItemType</th>
        <th>ItemSort</th>
        <th>Debug</th>
    </tr>
    <tr>
        <td><input type="text" name="SellerID" value=""></td>

        <td>
            <select name="GlobalID">
                <option value="EBAY-AU">Australia - EBAY-AU (15) -   AUD</option>
                <option value="EBAY-ENCA">Canada (English) - EBAY-ENCA (2) - CAD</option>
                <option value="EBAY-DE">Germany - EBAY-DE (77) - EUR</option>
                <option value="EBAY-GB">United Kingdom - EBAY-GB (3) - GBP</option>
                <option selected value="EBAY-US">United States - EBAY-US (0) - USD</option>
                <option selected value="EBAY-IN">INDIA - EBAY-IN (203) - INR</option>
            </select>
        </td>
        <td>
            <select name="ItemType">
                <option selected value="All">All Item Types</option>
                <option value="Auction">Auction Items Only</option>
                <option value="FixedPriced">Fixed Priced Item Only</option>
                <option value="StoreInventory">Store Inventory Only</option>
            </select>
        </td>
        <td>
            <select name="ItemSort">
                <option value="BidCountFewest">Bid Count (fewest bids first) [Applies to Auction Items Only]</option>
                <option selected value="EndTimeSoonest">End Time (soonest first)</option>
                <option value="PricePlusShippingLowest">Price + Shipping (lowest first)</option>
                <option value="CurrentPriceHighest">Current Price Highest</option>
            </select>
        </td>
        <td>
            <select name="Debug">
                <option value="1">true</option>
                <option selected value="0">false</option>
            </select>
        </td>

    </tr>
    <tr>
        <td colspan="4" align="center"><INPUT type="submit" name="submit" value="Search"></td>
    </tr>
 </table>
</form>

<?php
print $pageResults;
print $history;
$allItemsURL = "http://search.ebay.com/_W0QQsassZ" . $sellerID;
print "<p><a href=\"$allItemsURL\">See all items from this seller</a></p>";
?>

</body>
</html>

Content of the Class File which make Ebay API Query

<?php
 /**
 * Created by PhpStorm.
 * User: kapilsoni
 * Date: 13/11/15
 * Time: 2:37 AM
 */

 namespace Ebay_Profile;


 class SellerProfile
 {
 //    public $sellerName = '';
 //    public $siteID = '';
 //    public $debug;
 public $details = '';

 function __construct($idOfSeller,$globalID,$debug){

 //        $this->sellerName = $idOfSeller;
 //        $this->siteID = $globalID;
 //        $this->debug = $debug;

    $results = '';

    $apicall = "http://open.api.ebay.com/shopping?callname=GetUserProfile"
    . "&version=667"
    . "&siteid=$globalID"
    . "&appid=APIID"
    . "&UserID=$idOfSeller"
    . "&IncludeSelector=Details,FeedbackHistory"   // need Details to get   MyWorld info
    . "&responseencoding=XML";

    if ($debug) { print "<br />GetUserProfile call = <blockquote>$apicall   </blockquote>"; }

    $resp = simplexml_load_file($apicall);

    if($resp){

        //Setting Construction of html table
        $results .= "<table><tr>";

        //Setting User Image and Ebay Link of Seller
        //$results .= "<td><a href=\"" . $resp->User->MyWorldURL . "\"><img src=\""
        //    . $myWorldImgURL . "\"></a></td>";


        //Setting Seller ID
        $results .= "<td>Seller : $idOfSeller <br /> ";


        // Feedback Score
        $feedbackScore = $resp->User->FeedbackScore;
        $results .= "Feedback score : $feedbackScore <br />";


        //Calculate Feedback %
        $posCount = $resp->FeedbackHistory->UniquePositiveFeedbackCount;
        $negCount = $resp->FeedbackHistory->UniqueNegativeFeedbackCount;
        // PHP inbuilt Function 'sprintf()' — Return a formatted string
        $posFeedBackPct = sprintf("%01.1f", (100 * ($posCount / ($posCount + $negCount))));
        $results .= "Positive feedback : $posFeedBackPct%<br />";

        // PHP inbuilt Function 'substr()' — Return part of a string
        //$regDate = substr($resp->User->RegistrationDate, 0, 10);
        //$results .= "Registration date : $regDate<br />";

        $results .= "</tr></table>";

    }else {

        $results = "<h3> No user profile for seller $idOfSeller";

    }

    $this->details = $results;
    //return $results;

 }

//    function setProperty($idOfSeller,$globalID,$debug){
//
//        $this->sellerName = $idOfSeller;
//        $this->siteID = $globalID;
//        $this->debug = $debug;
//    
}
function __toString()
{
    // TODO: Implement __toString() method.
    return $this->details;

}
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
    • ¥15 这种微信登录授权 谁可以做啊
    • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
    • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
    • ¥15 网络设备配置与管理这个该怎么弄
    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!