Advertisement
Guest User

PHP No Headers

a guest
Dec 6th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?php
  2. $sql = $_POST['query'];
  3. if ($sql == ''){
  4. echo "Empty search!";
  5. }
  6. else{
  7. $result = mysqli_query($conn, $sql);
  8. if (($result)||(mysql_errno == 0))
  9. {
  10. echo "<table width='50%'><tr>";
  11. if (mysqli_num_rows($result)>0)
  12. {
  13. //loop thru the field names to print the correct headers
  14. //$i = 0;
  15. //while ($i < mysqli_num_fields($result))
  16. //{
  17. //echo "<th>". mysqli_fetch_fields($result) . "</th>";
  18. //$i++;
  19. //}
  20. //echo "</tr>";
  21.  
  22. //display the data
  23. while ($rows = mysqli_fetch_assoc($result))
  24. {
  25. echo "<tr>";
  26. foreach ($rows as $data)
  27. {
  28. echo "<td align='center'>". $data . "</td>";
  29. }
  30. }
  31. }else{
  32. echo "<tr><td colspan='" . ($i+1) . "'>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax.</td></tr>";
  33. }
  34. echo "</table>";
  35. }
  36. else{
  37. echo "Error in running query :". mysqli_error();
  38. }
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement