function similar to ASP execute()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpwalker
Forum Commoner
Posts: 81
Joined: Sun Apr 23, 2006 12:18 pm

function similar to ASP execute()

Post by phpwalker »

Hi all, I've been searching around but with no luck... may I know how to convert the following to php?

I know the process below is to declare new arrays using each of the field name taken from a table in a database.

Code: Select all

    for each field in list_items.fields
        exeStr = "redim "&field.name&"("&total_items&")"
        execute(exeStr)
    next
 
I've this attempt...

Code: Select all

 
    $SQL = "SELECT * FROM testing";
    
    $rs = mssql_query($SQL) or die('Error, query failed');  
    
    $fldname = array();
    
    $i = 0;
    while($fld = mssql_fetch_field($rs)){
        $fldname[$i] = $fld->name;        
        $i++;
    }
  
  //stuck here...
 
I'm stuck there...anyone can lend me a hand? thanks in advance!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: function similar to ASP execute()

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
phpwalker
Forum Commoner
Posts: 81
Joined: Sun Apr 23, 2006 12:18 pm

Re: function similar to ASP execute()

Post by phpwalker »

thanks for the fast reply, VladSun.

But include() and require() is not as what the ASP code intends to do.

Code: Select all

redim fieldname(number)
in asp is to declare array instead of include a page, correct me if i'm wrong. Anyone can help?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: function similar to ASP execute()

Post by VladSun »

OK, I got it :)
There is an equivalent - http://bg.php.net/eval, but I strongly advice you not to use it.

I think you should take a look at http://bg.php.net/mysql_fetch_assoc
There are 10 types of people in this world, those who understand binary and those who don't
phpwalker
Forum Commoner
Posts: 81
Joined: Sun Apr 23, 2006 12:18 pm

Re: function similar to ASP execute()

Post by phpwalker »

YAY!!!! That's the thing I'm looking for!!!!! Thanks a lot my friend! muacks! :P :P
Post Reply