i wanna make function to select data from database
<p>i wanna make function to select data from database</p>

<p>this is the function :</p>

<pre><code>function database_select ($select_code){
$result = mysql_query("$select_code");
$database_fetch_array = mysql_fetch_array($result);
return $database_fetch_array;
}
</code></pre>

<p>this is an example how to use it</p>

<pre><code>$select_code = "SELECT * FROM products";
$result = mysql_query("$select_code");
$database_fetch_array = mysql_fetch_array($result);
while($row = $database_fetch_array)
 {
$product_name= $row['product_name'];
echo "$product_name &lt;br /&gt;";
 }
</code></pre>

<p>but there is problem about this line</p>

<pre><code>while($row = $database_fetch_array)
</code></pre>

<p>that the data is repeated and it's the same data</p>

<p>if i replaced this code by this line</p>

<pre><code>while($row = mysql_fetch_array($result))
</code></pre>

<p>every thing is OK</p>

<p>Unfortunately, i want to put [ mysql_fetch_array($result) ] result into variable</p>

<p>to make it like </p>

<pre><code>while($row = $database_fetch_array)
</code></pre>

<p>or similar</p>

<p>any ideas ..!!</p>
