Answers for "how to fetch mysql data with speacial characters in php"

PHP
0

how to fetch mysql data with speacial characters in php

$sql2 = "SELECT name,email,contact FROM tbl_leadads";
  $result = mysqli_query($conn, $sql2);
  //print_r($result);die;
  if (mysqli_num_rows($result) > 0) {
    echo "<table><thead><tr><th>NAME</th><th>EMAIL</th><th>CONTACT</th></tr></thead>";
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
        //echo htmlspecialchars($row["name"]); 
        echo "<tr><td>".htmlentities($row["name"])."</td><td>".$row["email"]."</td><td> ".htmlentities($row["contact"])."</td></tr>";
    }
    echo "</table>";
  } else {
    echo "0 results";
  }
  mysqli_close($conn);
#try this
echo htmlspecialchars($string);
or
echo htmlentities($string);
//https://www.geeksforgeeks.org/htmlentities-vs-htmlspecialchars-function-in-php/#:~:text=htmlspecialchars()%20function%20convert%20the,applicable%20characters%20to%20HTML%20entities
Posted by: Guest on February-18-2021

Browse Popular Code Answers by Language