</header> <?php $connection = new DB_Class(); ?> <?php $connection->connect(); ?> <?php $query = "\nSELECT draftedFrom, COUNT(*) as nbr \nFROM Draft \nWHERE league = 'A' \nGROUP BY draftedFrom \nORDER BY nbr DESC"; ?> <p><?php echo $connection->count_results($query); ?> results found.</p> <?php $data = $connection->fetch($query); ?> <table class="table table-striped"> <thead> <tr> <th>Firstname</th> <th>Lastname</th> </tr> </thead> <tbody> <?php foreach ($data as $row) { ?> <tr> <td><?php echo $row[0];
include 'dbclass.php'; /** * Get type and do switch */ $query = $_REQUEST['query']; $table = "usr_web313_4"; /* IF Query starts with select */ $query_fields_start = strpos($query, 'SELECT'); if ($query) { $connection = new DB_Class($table); $connection->connect(); if ($query_fields_start == 0) { $query_fields_end = strpos($query, 'FROM'); $subfields = substr($query, $query_fields_start + 6, $query_fields_end - 6); $fields = split('[,]', $subfields); $result = $connection->fetch($query); ?> <table class="table table-striped"> <thead> <?php for ($i = 0; $i < count($fields); $i++) { ?> <th><?php echo $fields[$i]; ?> </th> <?php } ?> </thead> <tbody>