Jump to content

Select one "item" of all items the php script returns..


oskare100

Recommended Posts

Hello,
I'm trying to build a Ebay API system to leave feedback (I still need help with that in thread http://www.phpfreaks.com/forums/index.php/topic,120213.0.html in the PHP section) but here is another more specific question about XML.

This is how the code sample I got from ebay look like;
[code=php:0]
(The end of the file for the search code sample, full info about the function I want to use can be found at http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/io_GetFeedback.html)

else //no errors
{
//get results nodes
$itemNodes = $responseDoc->get_elements_by_tagname('Item');

//see if there are any results
if(count($itemNodes) > 0)
{
?>
<TABLE cellpadding="6" cellspacing="0" border="0">
<TR bgcolor="#BBBBBB">
<TD><B>Id</B></TD>
<TD><B>Title</B></TD>
<TD><B>Price</B></TD>
<TD><B>Started</B></TD>
<TD><B>Ends</B></TD>
</TR>
<?php
//stores the alternationg background colour of the rows
$bgColor = "#FFFFFF";
//go through each result
foreach($itemNodes as $item)
{
//get the required nodes from the results
$itemID = $item->get_elements_by_tagname('ItemID');
$title = $item->get_elements_by_tagname('Title');
$price = $item->get_elements_by_tagname('CurrentPrice');
$startTime = $item->get_elements_by_tagname('StartTime');
$endTime = $item->get_elements_by_tagname('EndTime');
$link = $item->get_elements_by_tagname('ViewItemURL');
//display the result in a table row
?>
<TR bgcolor="<?php echo $bgColor ?>">
<TD><?php echo $itemID[0]->get_content(); ?></TD>
<!-- Display the Title as a link to the item on eBay -->
<TD><A href="<?php echo $link[0]->get_content(); ?>" target="_blank">
<?php echo $title[0]->get_content(); ?>
</A>
</TD>
<TD><?php echo $price[0]->get_content(); ?></TD>
<TD><?php echo $startTime[0]->get_content(); ?> GMT</TD>
<TD><?php echo $endTime[0]->get_content(); ?> GMT</TD>
</TR>
<?php
//alternate the background colours
$bgColor = $bgColor == "#FFFFFF" ? "#EEEEEE" : "#FFFFFF";
} ?>
</TABLE>
<?php
}
else
{
echo '<P><B>No items found</B>';
}
}
}
?>[/code]

Is it possible to just select one or two of the items the script is returning and add variables as for example $item_id and so on to the selected item?

Thanks in advance,
/Oskar
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.