Jump to content

Does not display Username, Email and Admin values in table


Irresistable

Recommended Posts

I have pagination which should display all the Users along with there Email, and Admin status.

When testing the code, I recieve no errors, but the table does not load with the details. (It's just blank, like there is nothing in the database)

 

<?php
case 'admin':

 if($admin == 1)
 {
    echo '<p>
	WARNING - This is the Admin Center, take extra care when modifying</p><br />';

require_once ("Pagination/Paginated.php");
require_once ("Pagination/DoubleBarLayout.php");

  $us = mysql_query("SELECT Username FROM Users WHERE Username")or die(mysql_error());
  $names = mysql_fetch_array($us);
  
  $em = mysql_query("SELECT Email FROM Users WHERE Username")or die(mysql_error());
  $emails = mysql_fetch_array($em);
  
  $ad = mysql_query("SELECT Admin FROM Users WHERE Username")or die(mysql_error());
  $admins = mysql_fetch_array($ad);

$page = $_GET['page'];

//constructor takes three parameters
//1. array to be paged
//2. number of results per page (optional parameter. Default is 10)
//3. the current page (optional parameter. Default  is 1)
$pagedResults = new Paginated($names, 10, $page);
$pagedResults1 = new Paginated($emails, 10, $page);
$pagedResults2 = new Paginated($admins, 10, $page);

echo '<table width="200" border="1">';

while($row = $pagedResults->fetchPagedRow() & $row1 = $pagedResults1->fetchPagedRow() & $row2 = $pagedResults2->fetchPagedRow()) {	//when $row is false loop terminates
	echo '<tr><td>'.$row.'</td><td>'.$row1.'</td><td>'.$row2.'</td></tr>';
}

echo '</table>';

//important to set the strategy to be used before a call to fetchPagedNavigation
$pagedResults->setLayout(new DoubleBarLayout());
	$pagedResults1->setLayout(new DoubleBarLayout());
		$pagedResults2->setLayout(new DoubleBarLayout());

echo $pagedResults->fetchPagedNavigation();
	echo $pagedResults1->fetchPagedNavigation();
		echo $pagedResults2->fetchPagedNavigation();
?> 

Changed the queries to..

	  $us = mysql_query("SELECT Username FROM Users")or die(mysql_error());
  $emails = mysql_fetch_array($us);
  
  $em = mysql_query("SELECT Email FROM Users")or die(mysql_error());
  $emails = mysql_fetch_array($em);
  
  $ad = mysql_query("SELECT Admin FROM Users")or die(mysql_error());
  $admins = mysql_fetch_array($ad);

 

Though.. still doesn't recieve a value from the database.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.