Page 1 of 1

function similar to ASP execute()

Posted: Tue Jul 15, 2008 2:45 am
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!

Re: function similar to ASP execute()

Posted: Tue Jul 15, 2008 2:47 am
by VladSun

Re: function similar to ASP execute()

Posted: Tue Jul 15, 2008 2:50 am
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?

Re: function similar to ASP execute()

Posted: Tue Jul 15, 2008 2:55 am
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

Re: function similar to ASP execute()

Posted: Tue Jul 15, 2008 2:59 am
by phpwalker
YAY!!!! That's the thing I'm looking for!!!!! Thanks a lot my friend! muacks! :P :P