almost giving up pagination...wanna help?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

almost giving up pagination...wanna help?

Post by pleigh »

hi there, please read my code below

Code: Select all

<table width="100%" height="100%" border="1" bordercolor="#ffffff" cellpadding="0" cellspacing="0">
	<?
	$id = $_SESSION&#1111;'userID'];
	
	$query = "SELECT status FROM users WHERE userID='$id' and status='administrator'";
	$result = @mysql_query($query);
	if ($result)
	&#123;
		//verify administrator
		if ($row&#1111;0])
		&#123;
			$limit = 10;
			$query = "SELECT date, title, postID, firstname FROM posts AS p, users AS u 
			WHERE p.userID = u.userID ORDER BY date DESC LIMIT $limit";
			$result = @mysql_query($query);
		
			if ($result)
			&#123;
				echo "<tr align=center><td width=20%><table><tr><td><b>NAME</b></td></tr></table></td>
				<td width=60%><table><tr><td><b>TOPIC</b></td></tr></table></td>
				<td width=20%><table><tr><td><b>DATE</b></td></tr></table></td></tr>";
		
				while($row = mysql_fetch_array($result, MYSQL_NUM))
				&#123;
					$row&#1111;0] = '<font size=-2>'.date("F j, Y, g:i a").'</font>';
										
					echo "<tr><td width=20%><table><tr><td><b><a href="" class="under">$row&#1111;3]</a><b></td></tr></table></td>
					<td width=60%><table><tr><td><a href="reportview.php?pid=&#123;$row&#1111;2]&#125;" class="under">$row&#1111;1]</a></td></tr></table></td>
					<td width=20%><table><tr><td>$row&#1111;0]</td></tr></table></td></tr>";
				&#125;
				mysql_free_result($result);
				
				echo '<table align="right"><tr><td>Go to page 1, 
				<a href=report.php?report=$_GET&#1111;10] class="under">2, </td></tr></table>';			
				
			&#125;
			else
			&#123;
				echo 'system error!<br>'.mysql_error();
			&#125;
			mysql_close();
			
		&#125;
		//if not administrator
		else
		&#123;
			$query = "SELECT date, title, postID FROM posts WHERE userID='$id' ORDER BY date DESC";
			$result = @mysql_query($query);
		
			if ($result)
			&#123;
				echo "<tr align=center><td width=80%><table><tr><td><b>TOPIC</b></td></tr></table></td><td width=20%><table><tr><td><b>DATE</b></td></tr></table></td></tr>";
		
				while($row = mysql_fetch_array($result, MYSQL_NUM))
				&#123;
					//$post = $row&#1111;2];
					echo "<tr><td width=80%><table><tr><td><a href="reportview.php?pid=&#123;$row&#1111;2]&#125;" class="under">$row&#1111;1]</td></tr></table></td><td width=20%><table><tr><td>$row&#1111;0]</td></tr></table></td></tr>";
				&#125;
				mysql_free_result($result);			
			&#125;
			else
			&#123;
				echo 'system error!<br>'.mysql_error();
			&#125;
			mysql_close();
		&#125;		
	&#125;
				
	?>
		</table>
im stuck here, i tried to search the forum for a good tutorial, i found some, though, but wasn't able to do the same with mine...can't integrate it...i'm very new in php and mysql...maybe anybody out there can help modify this page....it'll be a great help for me.

thanks

pleigh
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you're stuck ... where?
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

thanks for the reply feyd...yup, i got stuck...code below...

Code: Select all

if ($row&#1111;0])
      &#123;
         $limit = 10;
         $query = "SELECT date, title, postID, firstname FROM posts AS p, users AS you
         WHERE p.userID = you.userID ORDER BY date DESC LIMIT $limit";
         $result = @mysql_query($query);
      
         if ($result)
         &#123;
            echo "<tr align=center><td width=20%><table><tr><td><b>NAME</b></td></tr></table></td>
            <td width=60%><table><tr><td><b>TOPIC</b></td></tr></table></td>
            <td width=20%><table><tr><td><b>DATE</b></td></tr></table></td></tr>";
      
            while($row = mysql_fetch_array($result, MYSQL_NUM))
            &#123;
               $row&#1111;0] = '<font size=-2>'.date("F j, Y, g:i a").'</font>';
                              
               echo "<tr><td width=20%><table><tr><td><b><a href="" class="under">$row&#1111;3]</a><b></td></tr></table></td>
               <td width=60%><table><tr><td><a href="reportview.php?pid=&#123;$row&#1111;2]&#125;" class="under">$row&#1111;1]</a></td></tr></table></td>
               <td width=20%><table><tr><td>$row&#1111;0]</td></tr></table></td></tr>";
            &#125;
            mysql_free_result($result);
            
            echo '<table align="right"><tr><td>Go to page 1,
            <a href=report.php?report=$_GET&#1111;10] class="under">2, </td></tr></table>';
what should i do??

and i think this line is not good too..

Code: Select all

echo '<table align="right"><tr><td>Go to page 1,
            <a href=report.php?report=$_GET&#1111;10] class="under">2, </td></tr></table>'
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

You can't include variables into a string if you use single quotes around it.

Change this

Code: Select all

echo '<table align="right"><tr><td>Go to page 1,
            <a href=report.php?report=$_GET&#1111;10] class="under">2, </td></tr></table>'
to this

Code: Select all

echo "<table align="right"><tr><td>Go to page 1,
            <a href="report.php?report=&#123;$_GET&#1111;10]&#125;" class="under">2, </td></tr></table>";
Also note the use of the brackets, they help PHP determine the full variable name and especially comes in handy when you are accessing array elements.

BTW - You ought to consider added the {} around the array elements in this line and others like it.

Code: Select all

echo "<tr><td width=20%><table><tr><td><b><a href="" class="under">$row&#1111;3]</a><b></td></tr></table></td>
               <td width=60%><table><tr><td><a href="reportview.php?pid=&#123;$row&#1111;2]&#125;" class="under">$row&#1111;1]</a></td></tr></table></td>
               <td width=20%><table><tr><td>$row&#1111;0]</td></tr></table></td></tr>";
Post Reply