oskare100 Posted December 30, 2006 Share Posted December 30, 2006 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=php:0] <?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 }[/code]Best RegardsOskar R Link to comment https://forums.phpfreaks.com/topic/32279-select-one-row-of-an-array-where-item-number-is/ Share on other sites More sharing options...
Wildhalf Posted December 30, 2006 Share Posted December 30, 2006 For the first part of your problem you could do something like this... I am using it on 2 of my sites at the minute...$refer_id = 1234(what ever you want);$sql = mysql_query("SELECT * FROM tblTable WHERE item_id='$refer_id'");$data = mysql_fetch_array($sql);//$data[item_ 1-5] are the values returned from the datatbase were each item is a header$item_1 = $data[item_1];$item_2 = $data[item_2];$item_3 = $data[item_3];$item_4 = $data[item_4];$item_5 = $data[item_5];$item_6 = $data[item_6];/* Let's strip some slashes in case the user enteredany escaped characters. */$item_id = stripslashes($item_id);$item_1 = stripslashes($item_1);$item_2 = stripslashes($item_2);$item_3 = stripslashes($item_3);$item_4 = stripslashes($item_4);$item_5 = stripslashes($item_5);$item_6 = stripslashes($item_6);//tests resultsprint "This is item $item_1\n";print "This is item $item_2\n";print "This is item $item_3\n";print "This is item $item_5\n";print "This is item $item_6\n";give it a go.....kieron Link to comment https://forums.phpfreaks.com/topic/32279-select-one-row-of-an-array-where-item-number-is/#findComment-149834 Share on other sites More sharing options...
oskare100 Posted December 30, 2006 Author Share Posted December 30, 2006 Hello,The MySQL thing was to compare what I want to do with something, the items returned are from Ebays XML API. Do you think your code would work anyway? Thanks./Oskar Link to comment https://forums.phpfreaks.com/topic/32279-select-one-row-of-an-array-where-item-number-is/#findComment-149855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.