Result without while loop

Thread Solved

Join Date: Apr 2008
Posts: 496
Reputation: veledrom is an unknown quantity at this point 
Solved Threads: 0
veledrom veledrom is offline Offline
Posting Pro in Training

Result without while loop

 
0
  #1
Feb 27th, 2009
Hi,

Code below always returns only 1 record therefore i don't need while. How can i get result without while loop?

Thanks

  1. $q="SELECT id FROM login WHERE username='$username'";
  2. $sql=mysql_query($q);
  3.  
  4. if (@mysql_num_rows($sql)==1) {
  5. while ($arr=mysql_fetch_array($sql)) {
  6. $id=$arr["id"];
  7. }
  8. }
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Result without while loop

 
0
  #2
Feb 27th, 2009
  1. $q="SELECT id FROM login WHERE username='$username'";
  2. $sql=mysql_query($q);
  3. if (@mysql_num_rows($sql)==1) {
  4. $arr=mysql_fetch_array($sql);
  5. $id=$arr["id"];
  6. }
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC