Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 10-31-2002, 08:07 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
creating dynamic variable names

i want to create a new variable name for each result of a query.

for example: ( this is bad code )
PHP Code:
<?
// some query here
for($i=0;$i<$num;$i++)
{
  
$object_$i=mysql_result($result,$i,"id");
}
?>
my goal would be to end up with variable names:
$object_0
$object_1
$object_2

is it possible to dynamically create variable names based on other variables?
sde is offline   Reply With Quote
Old 10-31-2002, 03:05 PM   #2 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
yes sir.
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 10-31-2002, 03:08 PM   #3 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
something like this:

PHP Code:
$price "1";
$i "1";

$price = ${"price$i"};

echo 
"$price1"
returns 1 (i think)
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 10-31-2002, 03:19 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
saweet, thanks. i've wondered what curley braces were for
sde is offline   Reply With Quote
Old 11-01-2002, 07:37 PM   #5 (permalink)
abc123
bloomberg
 
abc123's Avatar
 
Join Date: Jun 2002
Location: bloomberg
Posts: 263
abc123 is on a distinguished road
Send a message via AIM to abc123 Send a message via Yahoo to abc123
... isn't this what arrays are for?
__________________
-- bloomberg.
abc123 is offline   Reply With Quote
Old 11-02-2002, 09:03 AM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
Quote:
Originally posted by abc123
... isn't this what arrays are for?
errrr . duh. i didn't even think about making each object part of an array.

thanks.
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Labels in VB patelk MS Technologies ( ASP, VB, C#, .NET ) 0 10-26-2004 10:06 AM
Dynamic page names? bdl PHP 3 08-18-2003 11:04 AM
dynamic allocation..urgent help needed!!! kashif Standard C, C++ 4 04-21-2003 08:50 AM


All times are GMT -8. The time now is 03:56 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting