Jump to content

Recommended Posts

I haven't tested this code, but I know where the problem is.

<?php	 if($admin == 1)
 {
    echo '<p>
	WARNING - This is the Admin Center, take extra care when modifying</p><br />
  $username = $_SESSION['s_username'];
  $us = mysql_query("SELECT Username FROM Users WHERE Username = '$username'")or die(mysql_error());
  $names = mysql_fetch_array($us);
  
  $em = mysql_query("SELECT Email FROM Users WHERE Username = '$username'")or die(mysql_error());
  $emails = mysql_fetch_array($em);
  
  $ad = mysql_query("SELECT Admin FROM Users WHERE Username = '$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();';
 } else {
	echo '<p>
	You are not Admin, so do not attempt to access the Admin area by URL.</p>';
 }

	break;

       default:

	echo '<p>This is your Control Panel. Here you will be able to edit details of your registered account.</p>';

}

?>

 

This is where the Admin control panel will be, I am going to Display the Users table, with Email and Admin, with 10 a page.

Ignore the undefined variables, or when its needing another page. I have include page, at the top of the script which isn't shown here.

 

As you see, When the Admin control panel shows up, it defines and gets all the details for pagination, and then echo's the actual table.

 

As it echo's the table, it closes the previous echo and opens it back up. Which I'm beleiving that would not work. Also, even if that was sorted out, it would still not work either.. would it?

 

I'm not sure what to do with this.

Can you help me out with it.

Thanks

If I did the queries and arrays at the top of the page.

 

Then in the echo I called them, and did this.

 

<?php 	
case 'admin':

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

<table width="200" border="1">

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

</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();';
 } else {
	echo '<p>
	You are not Admin, so do not attempt to access the Admin area by URL.</p>';
 }

	break;

       default:

	echo '<p>This is your Control Panel. Here you will be able to edit details of your registered account.</p>';

}

?>

 

Would this be better, I still think theres issues with it though.

Look at the syntax highlighting. Get Notepad++ or another editor that highlights syntax... if the colors are off, your code is screwed up either way. Fix the syntax errors (which are basic) then work on the logistics.

 

Just a note, you do have to close your syntax properly before running another set of php codes, echo's are not a catch all, open it and the code will run. You have to close them when you are done with the statement before you can execute anymore PHP code. I would really go look up the basics of PHP syntax if I were you before I continued coding, as it does seem that you lack that knowledge. (Not to be rude, but it will help knowing the syntax's do's and don'ts).

I sorted it, I know the syntax, but not fully. So i'll have to have a look at that. I downloaded Notepad++, the highlighting is good. However, I knew what the problem was.

 

As I looked at the code, it gets the case, asks for admin, and opens the bracket, so there for it doesn't matter how many echo's involved. :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.