how to fetch mysql data with speacial characters in php

Solutions on MaxInterview for how to fetch mysql data with speacial characters in php by the best coders in the world

showing results for - "how to fetch mysql data with speacial characters in php"
Yusuf
07 Jan 2020
1$sql2 = "SELECT name,email,contact FROM tbl_leadads";
2  $result = mysqli_query($conn, $sql2);
3  //print_r($result);die;
4  if (mysqli_num_rows($result) > 0) {
5    echo "<table><thead><tr><th>NAME</th><th>EMAIL</th><th>CONTACT</th></tr></thead>";
6    // output data of each row
7    while($row = mysqli_fetch_assoc($result)) {
8        //echo htmlspecialchars($row["name"]); 
9        echo "<tr><td>".htmlentities($row["name"])."</td><td>".$row["email"]."</td><td> ".htmlentities($row["contact"])."</td></tr>";
10    }
11    echo "</table>";
12  } else {
13    echo "0 results";
14  }
15  mysqli_close($conn);
16#try this
17echo htmlspecialchars($string);
18or
19echo htmlentities($string);
20//https://www.geeksforgeeks.org/htmlentities-vs-htmlspecialchars-function-in-php/#:~:text=htmlspecialchars()%20function%20convert%20the,applicable%20characters%20to%20HTML%20entities