Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to Print some dynamically data from my function to passing string in function like this.

My Function
PHP
function mysql_funX_Repeter($query,$itemtemplet)
{
    $this->mysql_funX_connect();

    $result = mysql_query($query) or die("Repeter Query Error.");
    if (!$result) 
    {
        $message = 'ERROR:' . mysql_error();
        return $message;
    }
    else
    {
        $newtempelt = str_replace("Eval", '$row', $itemtemplet);
        while ($row = mysql_fetch_array($result)) 
        {

            echo $newtempelt;
        }
    }
}


Passing Value In Function
HTML
<ul>

PHP
<?php
$rptvalue="<li><a href=''>Eval['name']</a></li>";
$myFun->mysql_funX_Repeter("Select name from tbldemo",$rptvalue);
?>
HTML
</ul>


My Output

  • $row['name']
  • $row['name']
  • $row['name']


I want Output

  • raj
  • ram
  • prince



But it's Show me only variable but not show it's database value. How to solve this...!!!
Posted
Comments
Mohibur Rashid 3-Apr-15 4:50am    
First of all, bad programming approach. secondly try eval function, you may be able to come up with something. Again, bad programming approach.
Priyank.Patel00762 4-Apr-15 2:30am    
How to use Eval Function to get data from database like this...!!!
I don't know about eval. I am beginner in php. Please Help me sir...!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900