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 5 of 5
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,673
    Thanks
    28
    Thanked 4 Times in 4 Posts

    How do ı just select the first row ?

    I am running a quich search on my transaction file to
    pick up the client id number.

    the transaction file may have several rows for that client
    and I can identify them from another field, the subscription number.

    This is the php that I have:

    PHP Code:
    $sql "select client_id from transactions where subscr_id = '$Db_subscr_id'";
    $result mysql_query($sql) or die("Find Transaction to Modify query failed:"mysql_error());  
    $num mysql_num_rows($result);

    if (
    $num == 0) {
       
    Handle the error
       
    // end if    
    else { 
    Now there could be many rows with the same subscrition number
    and all of them will have the same client id number.

    So after this else I want to gab the first row in the result array
    and find out what the client_id value is.

    How do I get the first on ?

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    $sql = "select client_id from transactions where subscr_id = '$Db_subscr_id' LIMIT 1";



    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    ... and then
    PHP Code:
    $row mysql_fetch_array($result);
    $client_id $row['client_id']; 

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    oh good call, I didn't see that part.

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #5
    Senior Coder
    Join Date
    May 2006
    Posts
    1,673
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Thanks for helping


  •  

    Posting Permissions

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