RE: [PHP] Unique Names for Variable in Loop

2006-02-02 Thread Jim Moseby
 
 I must be brain dead today since I can't get my syntax correct.
 
 Simple MySQL query to return a list of last_name. No problem. Each  
 last name returned needs to be assigned to a unique variable like  
 name1, name2, name3, etc.

How about $names[1], $names[2], $names[3]?

JM

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



RE: [PHP] Unique Names for Variable in Loop

2006-02-02 Thread Jim Moseby
  
  I must be brain dead today since I can't get my syntax correct.
  
  Simple MySQL query to return a list of last_name. No problem. Each  
  last name returned needs to be assigned to a unique variable like  
  name1, name2, name3, etc.
 
 How about $names[1], $names[2], $names[3]?
 
 JM

To expand a bit:

$index=0;
while ($row=mysql_fetch_array($result)){
  $names[$index]=$row['lastname'];
  $index++;
}

JM

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



RE: [PHP] Unique Names for Variable in Loop

2006-02-02 Thread Programmer


$x = 0;
my_name_array = array();

While($row=mysql_fetch_array($result))
{
my_name_array[$x] = $row[last_name];
}

Jeremy Schreckhise

-Original Message-
From: Albert Padley [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 02, 2006 1:15 PM
To: php-general@lists.php.net
Subject: [PHP] Unique Names for Variable in Loop

I must be brain dead today since I can't get my syntax correct.

Simple MySQL query to return a list of last_name. No problem. Each  
last name returned needs to be assigned to a unique variable like  
name1, name2, name3, etc.

Somebody just kick me in the right direction.

Thanks.

Al Padley

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

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



RE: [PHP] Unique Names for Variable in Loop

2006-02-02 Thread Programmer
Oops you might want to increment $x++ after the assignment.



-Original Message-
From: Programmer [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 02, 2006 1:49 PM
To: 'Albert Padley'; php-general@lists.php.net
Subject: RE: [PHP] Unique Names for Variable in Loop



$x = 0;
my_name_array = array();

While($row=mysql_fetch_array($result))
{
my_name_array[$x] = $row[last_name];
}

Jeremy Schreckhise

-Original Message-
From: Albert Padley [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 02, 2006 1:15 PM
To: php-general@lists.php.net
Subject: [PHP] Unique Names for Variable in Loop

I must be brain dead today since I can't get my syntax correct.

Simple MySQL query to return a list of last_name. No problem. Each  
last name returned needs to be assigned to a unique variable like  
name1, name2, name3, etc.

Somebody just kick me in the right direction.

Thanks.

Al Padley

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

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

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



Re: [PHP] Unique Names for Variable in Loop

2006-02-02 Thread Albert Padley

Yes, that's it. Thanks for the swift kick.

AP


On Feb 2, 2006, at 12:37 PM, Jim Moseby wrote:



I must be brain dead today since I can't get my syntax correct.

Simple MySQL query to return a list of last_name. No problem. Each
last name returned needs to be assigned to a unique variable like
name1, name2, name3, etc.


How about $names[1], $names[2], $names[3]?

JM

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



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



Re: [PHP] Unique Names for Variable in Loop

2006-02-02 Thread Richard Lynch
On Thu, February 2, 2006 1:15 pm, Albert Padley wrote:
 I must be brain dead today since I can't get my syntax correct.

 Simple MySQL query to return a list of last_name. No problem. Each
 last name returned needs to be assigned to a unique variable like
 name1, name2, name3, etc.

 Somebody just kick me in the right direction.

What you describe is a Variable Variable.
The right direction is an array.
:-)
http://php.net/ documents both in readily-found sections.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



RE: [PHP] Unique Names for Variable in Loop

2006-02-02 Thread Miles Thompson


No need to subscript them, my_name_array[] will work just fine.

Miles

At 03:49 PM 2/2/2006, Programmer wrote:




$x = 0;
my_name_array = array();

While($row=mysql_fetch_array($result))
{
my_name_array[$x] = $row[last_name];
}

Jeremy Schreckhise

-Original Message-
From: Albert Padley [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 02, 2006 1:15 PM
To: php-general@lists.php.net
Subject: [PHP] Unique Names for Variable in Loop

I must be brain dead today since I can't get my syntax correct.

Simple MySQL query to return a list of last_name. No problem. Each
last name returned needs to be assigned to a unique variable like
name1, name2, name3, etc.

Somebody just kick me in the right direction.

Thanks.

Al Padley

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

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



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 267.15.0/248 - Release Date: 2/1/2006

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



Re: [PHP] Unique Names for Variable in Loop

2006-02-02 Thread Ligaya Turmelle
or you can forget about keeping track of the indexes and just use 
array_push or the even simpler $names[]=$row['lastname'];


Jim Moseby wrote:

I must be brain dead today since I can't get my syntax correct.

Simple MySQL query to return a list of last_name. No problem. Each  
last name returned needs to be assigned to a unique variable like  
name1, name2, name3, etc.


How about $names[1], $names[2], $names[3]?

JM



To expand a bit:

$index=0;
while ($row=mysql_fetch_array($result)){
  $names[$index]=$row['lastname'];
  $index++;
}

JM



--

life is a game... so have fun.

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