Rama Lingam Rama Lingam - 7 months ago 11
SQL Question

Cannot get values insight <<Some_text_here>> or <some_text_here> from MSQL using PHP

I cannot get the values insight single<......> or double<<....>> symbol from mysql.

It's always return <> or <<>>.

Mysql Data:
enter image description here

Sample Code :

$sql = "SELECT id,html_form_data FROM `user_detail`";
$result = mysqli_query($con, $sql);
while($row = mysqli_fetch_assoc($result))
{
$getFormData[] = $row;
}
print_r($getFormData);


Getting Result:


Array ( [0] => Array ( [id] => 1 [html_form_data] => ) 1 => Array ( [id] => 2 [html_form_data] => <> ) )


Note : I am geting the values after interchanged the <.....> into $.....$

But I know that any reason for return it? or any ways to getting values?

Answer

As I earlier mentioned in the comments try printing your $getFormData like this:

array_map("printHTML", $getFormData);

function printHTML($a) {
  echo htmlentities($a)."<br/>";
}

Note: This is for your testing. This handles only one dimensional array for now.

This handles multidimensional array:

function printHTML($a) {
  if(!is_array($a))
    echo htmlentities($a)."<br/>";
  else
    array_map("printHTML", $a);
}