Select one row of an array where item number is ..?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oskare100
Forum Commoner
Posts: 80
Joined: Sun Oct 29, 2006 5:47 am

Select one row of an array where item number is ..?

Post by oskare100 »

Hello,
When I call the Ebays XML API I get an array or something similar back (see the code sample), is it possible to "select item_id where item_id = 123123" or something similar as in MySQL? If, How can I do that? Also, I need to attach a PHP variables to the row I selected as for example $starttime, $endtime and so on.

Here is the code sample (the end of the scritpt);

Code: Select all

<?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[2]->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
			}
Best Regards
Oskar R
Post Reply