Re: no temp var for mysql_fetch_array results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





>Hi, all --

>I have some code which looks about like

>  if ( $_POST['signup']['referrer'] )                       # a friend?
 > {
 >   $q = "select InvitedBy from customer where EMail
= '{$_POST['signup']['referrer']}'" ;
 >   $r = mysql_query($q,$dbro) ;
 >   $row = mysql_fetch_array($r) ;
 >   $i = $row[0] ;
 > }
 > else
 # no referrer supplied
 >   { $i = '' ; }

>and I would really prefer not to have to use $row just to set $i.  Since
>mysql_fetch_array() returns an array, and I know I want a field from just
>this one row (not looping), could I just

>  $i = mysql_fetch_array($r)[0] ;

Hi David....
      How about:
      $i = mysql_result(mysql_query($q,$dbro),0);
HTH
Jeff

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux