Advertisement
Guest User

Untitled

a guest
Mar 11th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. <?php
  2.  
  3. $html = file_get_html('http://itecdigital.org.uk/2015/430926/BeautyFactoryBooking/admin.php');
  4.  
  5. $dom = new DOMDocument();
  6. $dom->loadHTML($html);
  7.  
  8. $elements = $dom->getElementsByTagName('tr');
  9. //Loop through each row
  10. foreach ($rows as $row) {
  11. //Loop through each child (cell) of the row
  12. foreach ($row->children() as $cell) {
  13. echo $cell->plaintext; // Display the contents of each cell - this is the value you want to extract
  14. }
  15. }
  16.  
  17. ?>
  18.  
  19. <?php
  20.  
  21. echo "<table style='border: solid 1px black;'>";
  22. echo "<tr><th>Id</th><th>First Name</th><th>Last Name</th><th>Email Address</th><th>Phone Num</th><th>Treatment</th><th>Date</th><th>Time</th><th>Message</th><th>Reply</th></tr>";
  23.  
  24. class TableRows extends RecursiveIteratorIterator {
  25. function __construct($it) {
  26. parent::__construct($it, self::LEAVES_ONLY);
  27. }
  28.  
  29. function current() {
  30. return "<td style='width:100px;border:1px solid black;'>" . parent::current(). "</td>";
  31. }
  32.  
  33. function beginChildren() {
  34. echo "<tr>";
  35. }
  36.  
  37. function endChildren() {
  38. echo "</tr>" . "n";
  39. }
  40. }
  41.  
  42. $servername = "#";
  43. $username = "#";
  44. $password = "#";
  45. $dbname = "#";
  46.  
  47. try {
  48. $conn = new PDO("mysql: host=$servername; dbname=$dbname", $username, $password);
  49. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  50. $stmt = $conn->prepare("SELECT Booking_request_form.id_booking, Client_Information.first_name, Client_Information.last_name, Client_Information.email_address, Client_Information.phone_number, Booking_request_form.treatment, Booking_request_form.date, Booking_request_form.time, Booking_request_form.message FROM Booking_request_form INNER JOIN Client_Information WHERE Client_Information.id_client=Booking_request_form.client_fk");
  51.  
  52. $stmt->execute();
  53.  
  54. // set the resulting array to associative
  55. $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
  56. foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
  57. echo $v;
  58. }
  59. }
  60.  
  61. catch(PDOException $e) {
  62. echo "Error: " . $e->getMessage();
  63. }
  64.  
  65. $conn = null;
  66. echo "</table>";
  67.  
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement