Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    57
    Thanks
    2
    Thanked 0 Times in 0 Posts

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

    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);
    PHP Code:
                <?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
    Last edited by oskare100; 12-30-2006 at 01:18 PM.

  • #2
    New Coder
    Join Date
    Nov 2006
    Location
    UK
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If it is coming back as a (php) array you should be able to use:

    $the_array['YourItemCodeHere']
    - Mark

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, It seems that your particular question is how can I make an sql call to get all the information I need.

    If this is the case, $result=mysql_query(Select info1,info2,info3 from Table WHERE something=something);

    That is the basic syntax.
    This will reveal a resource so you will also need to do something like mysql_fetch_row or mysql_fetch_array, there really is no difference when applying it in this manner. In other manners fetch row will return the rows affected whereas array will return full results.

    So if we use this: $row=mysql_fetch_row($result);
    $row['info1'] will equal info1 from the sql call and so on.

    I hope this helps, if not, could you clear it up, Im shooting at what I think you need.

  • #4
    Regular Coder xconspirisist's Avatar
    Join Date
    Jun 2006
    Location
    Great Britain.
    Posts
    138
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Please print the result of:

    PHP Code:
    print_r($itemNodes); 
    Then we will know what $itemNodes is, and it's structure. From there we will be able to tell you how to itterate over it.
    If I have been helpful, use the "thank" button - It makes me happy!

    xconspirisist.co.uk - homepage of my online alias
    technowax.net - a community for people interested in all forms of modern technology.

  • #5
    New Coder
    Join Date
    Dec 2006
    Posts
    57
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Darklord View Post
    Well, It seems that your particular question is how can I make an sql call to get all the information I need.

    If this is the case, $result=mysql_query(Select info1,info2,info3 from Table WHERE something=something);

    That is the basic syntax.
    This will reveal a resource so you will also need to do something like mysql_fetch_row or mysql_fetch_array, there really is no difference when applying it in this manner. In other manners fetch row will return the rows affected whereas array will return full results.

    So if we use this: $row=mysql_fetch_row($result);
    $row['info1'] will equal info1 from the sql call and so on.

    I hope this helps, if not, could you clear it up, Im shooting at what I think you need.
    Hello,
    Thanks for your reply. The MySQL thing was only to compare what I want to do with something, the items returned are from Ebays XML API. Would it work to do something similar with the XML array return from Ebay?

    /Oskar

  • #6
    New Coder
    Join Date
    Dec 2006
    Posts
    57
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by xconspirisist View Post
    Please print the result of:

    PHP Code:
    print_r($itemNodes); 
    Then we will know what $itemNodes is, and it's structure. From there we will be able to tell you how to itterate over it.
    Hello,
    If I input the name of one auction I get the following results;

    Array ( [0] => domelement Object ( [type] => 1 [tagname] => Item [0] => 6 [1] => 144398648 ) )
    And if I input just a search term I get the follwing results;

    Array ( [0] => domelement Object ( [type] => 1 [tagname] => Item [0] => 6 [1] => 143954024 ) [1] => domelement Object ( [type] => 1 [tagname] => Item [0] => 7 [1] => 143987448 ) [2] => domelement Object ( [type] => 1 [tagname] => Item [0] => 8 [1] => 144041536 ) ) Array ( [0] => domelement Object ( [type] => 1 [tagname] => Item [0] => 6 [1] => 143954024 ) [1] => domelement Object ( [type] => 1 [tagname] => Item [0] => 7 [1] => 143987448 ) [2] => domelement Object ( [type] => 1 [tagname] => Item [0] => 8 [1] => 144041536 ) ) Array ( [0] => domelement Object ( [type] => 1 [tagname] => Item [0] => 6 [1] => 143954024 ) [1] => domelement Object ( [type] => 1 [tagname] => Item [0] => 7 [1] => 143987448 ) [2] => domelement Object ( [type] => 1 [tagname] => Item [0] => 8 [1] => 144041536 ) )
    Thanks in advance,
    /Oskar
    Last edited by oskare100; 12-30-2006 at 04:23 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •