Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-05-2009, 03:38 PM   PM User | #1
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,526
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
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 ?
jeddi is offline   Reply With Quote
Old 09-05-2009, 03:40 PM   PM User | #2
whizard
Senior Coder

 
whizard's Avatar
 
Join Date: Jan 2005
Location: Philadelphia, PA, USA
Posts: 1,457
Thanks: 10
Thanked 37 Times in 37 Posts
whizard will become famous soon enoughwhizard will become famous soon enough
$sql = "select client_id from transactions where subscr_id = '$Db_subscr_id' LIMIT 1";



Dan
__________________
If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.
Step 1: Learn. Step 2: Search. Step 3: Post here.
whizard is offline   Reply With Quote
Old 09-05-2009, 03:43 PM   PM User | #3
SKDevelopment
Regular Coder

 
Join Date: Mar 2006
Posts: 238
Thanks: 3
Thanked 37 Times in 37 Posts
SKDevelopment has a little shameless behaviour in the past
... and then
PHP Code:
$row mysql_fetch_array($result);
$client_id $row['client_id']; 
__________________
PHP Programmer
SKDevelopment is offline   Reply With Quote
Old 09-05-2009, 03:44 PM   PM User | #4
whizard
Senior Coder

 
whizard's Avatar
 
Join Date: Jan 2005
Location: Philadelphia, PA, USA
Posts: 1,457
Thanks: 10
Thanked 37 Times in 37 Posts
whizard will become famous soon enoughwhizard will become famous soon enough
oh good call, I didn't see that part.

Dan
__________________
If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.
Step 1: Learn. Step 2: Search. Step 3: Post here.
whizard is offline   Reply With Quote
Old 09-05-2009, 04:19 PM   PM User | #5
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,526
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
Thanks for helping
jeddi is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:06 PM.


Advertisement
Log in to turn off these ads.