note 100702 deleted from function.mysql-fetch-array by danbrown

From: Date: Mon, 01 Nov 2010 12:40:13 +0000
Subject: note 100702 deleted from function.mysql-fetch-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173647@lists.php.net to get a copy of this message
Note Submitter: Siroos Sheikhi ---- we can use our query result like as dataset in .net & mssql for this we should write a function to convert mysql query result to an array like as table ! i wrote a simple & short function for this : function result2dataset($query) { $result=mysql_query($query,$mysqlconnection); $r=array(); while($row=mysql_fetch_array($result,MYSQLI_BOTH)) //you can use MYSQL_NUM , or MYSQL_ASSOC as you want $r[]=$row; return $r; } //now use function $q="select f1,f2,f3 from table"; $dataset=result2dataset($q); foreach($dataset as $row) { echo $row[0].$row['f2'].$row[2]; //call by filed name or number is dependent on MYSQL_BOTH,MYSQL_NUM or MYSQL_ASSOC }

« previous php.notes (#173647) next »