Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo "<table style='cursor: pointer;' class='table table-hover table-striped
- table-bordered table-responsive ' >";
- echo "<tr>
- <th>Company Name</th>
- <th>Contact Person</th>
- <th>Client Address</th>
- <th>Contact no.</th>
- <th>E-mail</th>
- <th>User Birthdate</th>
- <th>User Mobile no.</th>
- <th>Username</th>
- <th>User Fistname</th>
- <th>User Lastname</th>
- <th>User Birthdate</th>
- </tr>";
- class TableRows extends RecursiveIteratorIterator {
- function __construct($it) {
- parent::__construct($it, self::LEAVES_ONLY);
- }
- function current() {
- return "<td>" . parent::current(). "</td>";
- }
- function beginChildren() {
- echo "<tr class='table table-hover'>";
- }
- function endChildren() {
- echo "</tr>" . "n";
- }
- }
- $servername = "mysql5013.hostbuddy.com";
- $username = "*****_crb";
- $password = "*****";
- $dbname = "db_*****_crb";
- try {
- //data from client table
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username,
- $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $stmt = $conn->prepare("SELECT cli_company_name, cli_contact_person,
- cli_address, cli_contactno, cli_email FROM client WHERE status=1 ");
- $stmt->execute();
- // set the resulting array to associative
- $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
- //data from useraccounts table
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $stmt2 = $conn->prepare("SELECT username, user_fname, user_lname, user_bdate
- FROM useraccounts WHERE status=1 AND
- company_name='".$result['cli_company_name']."' ");
- $stmt2->execute();
- // set the resulting array to associative
- $result2 = $stmt2->setFetchMode(PDO::FETCH_ASSOC);
- foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as
- $k=>$v) {
- echo $v;
- }
- foreach(new TableRows(new RecursiveArrayIterator($stmt2->fetchAll())) as
- $l=>$w) {
- echo $w;
- }
- }
- catch(PDOException $e) {
- echo "Error: " . $e->getMessage();
- }
- $conn = null;
- echo "</table>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement