some other approach
This commit is contained in:
parent
4547df736f
commit
801768e85f
@ -28,46 +28,36 @@ if($_SESSION['isadmin'] == 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '<div class="alert alert-danger" role="alert">heres the admin world</div>';
|
echo '<div class="alert alert-danger" role="alert">heres the admin world</div>';
|
||||||
?>
|
|
||||||
<?php
|
|
||||||
include 'db.inc.php';
|
|
||||||
|
|
||||||
|
|
||||||
//create connection
|
// Run the query.
|
||||||
$connection = mysqli_connect($mysqlhost, $dbuser, $dbpass, $dbname);
|
$result = $pdo->query("SELECT * FROM table LIMIT 10");
|
||||||
|
|
||||||
//test if connection failed
|
// Get the result in to a more usable format.
|
||||||
if(mysqli_connect_errno()){
|
$query = array();
|
||||||
die("connection failed: "
|
while($query[] = mysqli_fetch_assoc($result));
|
||||||
. mysqli_connect_error()
|
array_pop($query);
|
||||||
. " (" . mysqli_connect_errno()
|
|
||||||
. ")");
|
// Output a dynamic table of the results with column headings.
|
||||||
|
echo '<table border="1">';
|
||||||
|
echo '<tr>';
|
||||||
|
foreach($query[0] as $key => $value) {
|
||||||
|
echo '<td>';
|
||||||
|
echo $key;
|
||||||
|
echo '</td>';
|
||||||
}
|
}
|
||||||
|
echo '</tr>';
|
||||||
//get results from database
|
foreach($query as $row) {
|
||||||
$result = mysqli_query($connection,"SELECT * FROM users");
|
echo '<tr>';
|
||||||
$all_property = array(); //declare an array for saving property
|
foreach($row as $column) {
|
||||||
|
echo '<td>';
|
||||||
//showing property
|
echo $column;
|
||||||
echo '<table class="data-table">
|
echo '</td>';
|
||||||
<tr class="data-heading">'; //initialize table tag
|
|
||||||
while ($property = mysqli_fetch_field($result)) {
|
|
||||||
echo '<td>' . $property->name . '</td>'; //get field name for header
|
|
||||||
array_push($all_property, $property->name); //save those to array
|
|
||||||
}
|
|
||||||
echo '</tr>'; //end tr tag
|
|
||||||
|
|
||||||
//showing all data
|
|
||||||
while ($row = mysqli_fetch_array($result)) {
|
|
||||||
echo "<tr>";
|
|
||||||
foreach ($all_property as $item) {
|
|
||||||
echo '<td>' . $row[$item] . '</td>'; //get items using property value
|
|
||||||
}
|
}
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo '</table>';
|
||||||
?>
|
|
||||||
<?php
|
|
||||||
echo '<br /> <br />';
|
echo '<br /> <br />';
|
||||||
echo '<a href="adminarea.php"><button class="btn btn-info">Back</button></a>';
|
echo '<a href="adminarea.php"><button class="btn btn-info">Back</button></a>';
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user