Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. <?php
  2. echo "<table style='cursor: pointer;' class='table table-hover table-striped
  3. table-bordered table-responsive ' >";
  4. echo "<tr>
  5. <th>Company Name</th>
  6. <th>Contact Person</th>
  7. <th>Client Address</th>
  8. <th>Contact no.</th>
  9. <th>E-mail</th>
  10. <th>User Birthdate</th>
  11. <th>User Mobile no.</th>
  12. <th>Username</th>
  13. <th>User Fistname</th>
  14. <th>User Lastname</th>
  15. <th>User Birthdate</th>
  16. </tr>";
  17.  
  18. class TableRows extends RecursiveIteratorIterator {
  19. function __construct($it) {
  20. parent::__construct($it, self::LEAVES_ONLY);
  21. }
  22.  
  23. function current() {
  24. return "<td>" . parent::current(). "</td>";
  25. }
  26.  
  27. function beginChildren() {
  28. echo "<tr class='table table-hover'>";
  29. }
  30.  
  31. function endChildren() {
  32. echo "</tr>" . "n";
  33. }
  34. }
  35.  
  36. $servername = "mysql5013.hostbuddy.com";
  37. $username = "*****_crb";
  38. $password = "*****";
  39. $dbname = "db_*****_crb";
  40.  
  41. try {
  42. //data from client table
  43. $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username,
  44. $password);
  45. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  46. $stmt = $conn->prepare("SELECT cli_company_name, cli_contact_person,
  47. cli_address, cli_contactno, cli_email FROM client WHERE status=1 ");
  48. $stmt->execute();
  49.  
  50. // set the resulting array to associative
  51. $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
  52.  
  53. //data from useraccounts table
  54. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  55. $stmt2 = $conn->prepare("SELECT username, user_fname, user_lname, user_bdate
  56. FROM useraccounts WHERE status=1 AND
  57. company_name='".$result['cli_company_name']."' ");
  58. $stmt2->execute();
  59.  
  60. // set the resulting array to associative
  61. $result2 = $stmt2->setFetchMode(PDO::FETCH_ASSOC);
  62.  
  63. foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as
  64. $k=>$v) {
  65. echo $v;
  66. }
  67.  
  68. foreach(new TableRows(new RecursiveArrayIterator($stmt2->fetchAll())) as
  69. $l=>$w) {
  70. echo $w;
  71. }
  72. }
  73. catch(PDOException $e) {
  74. echo "Error: " . $e->getMessage();
  75. }
  76. $conn = null;
  77. echo "</table>";
  78. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement