Jump to content


Page Numbering Help!


5 replies to this topic

#1 birdbrain24

    Young Padawan

  • Members
  • Pip
  • 9 posts
  • Gender:Male
  • Location:Ontario, Canada
  • Interests:HTML, PHP and MySQL Coding

Posted 11 July 2007 - 01:42 PM

Could Someone Add Page Numbering To The Bottom Of This Script I Have Tried Several Times And Had No Success!

<link rel=stylesheet href=../style.css type=text/css><BR><?php<BR>include"mysql_connect.php";<BR>include"functions.php";</P> <P>$username=$_SESSION['username'];</P> <P>$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));<BR>$userlevel=$fetch->userlevel;</P> <P>$topics=mysql_fetch_object(mysql_query("SELECT * FROM topics WHERE id='$username'"));</P> <P>$date=gmdate('F jS Y');<BR>$time=gmdate('g:i:s a');<BR>$datetime="$date at $time";</P> <P>?><BR><form id="form" name="form" method="post" action="newtopic.php"><BR>  <input type="submit" name="Submit" value="New Topic!" /><BR></form><BR><table width=400 border=1 cellpadding=2 cellspacing=0 bordercolor=black class=table align=center><BR>  <tr><BR>	<td width=100% align=center class=header colspan=2>Forum</td><BR>	</tr></P> <P><?php<BR>$query = mysql_query("SELECT * FROM `topics` WHERE `type`='important' ORDER BY `lastpost` DESC");<BR>while($topics=mysql_fetch_object($query)){</P> <P>if($topics->type == "important"){</P> <P>if($userlevel == "Admin"){<BR>echo "<tr><td class=text><u><b>Important:</b></u> "; <BR>echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";<BR>if ($topics->locked == "Yes" ){ echo" (Locked)"; } <BR>echo"</td><BR><td><BR><a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a><BR></td><BR></tr>";<BR>}</P> <P>if($userlevel == "Head"){<BR>echo "<tr><td class=text><u><b>Important:</b></u> "; <BR>echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";<BR>if ($topics->locked == "Yes" ){ echo" (Locked)"; } <BR>echo"</td><BR><td><BR><a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a><BR></td><BR></tr>";<BR>}</P> <P>if($userlevel == "Mod"){<BR>echo "<tr><td class=text><u><b>Important:</b></u> "; <BR>echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";<BR>if ($topics->locked == "Yes" ){ echo" (Locked)"; } <BR>echo"</td><BR><td><BR><a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a><BR></td><BR></tr>";<BR>}</P> <P>if($userlevel == "Users"){<BR>echo "<tr><td class=text><u><b>Important:</b></u> "; <BR>echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";<BR>if ($topics->locked == "Yes" ){ echo" (Locked)"; } <BR>echo"</td></tr>";<BR>}<BR>}<BR>}</P> <P>$query = mysql_query("SELECT * FROM `topics` WHERE `type`='sticky' ORDER BY `lastpost` DESC");<BR>while($topics=mysql_fetch_object($query)){</P> <P>if($topics->type == "sticky"){</P> <P>if($userlevel == "Admin"){<BR>echo "<tr><td class=text><u>Sticky:</u> "; <BR>echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";<BR>if ($topics->locked == "Yes" ){ echo" (Locked)"; } <BR>echo"</td><BR><td><BR><a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a><BR></td><BR></tr>";<BR>}</P> <P>if($userlevel == "Head"){<BR>echo "<tr><td class=text><u>Sticky:</u> "; <BR>echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";<BR>if ($topics->locked == "Yes" ){ echo" (Locked)"; } <BR>echo"</td><BR><td><BR><a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a><BR></td><BR></tr>";<BR>}</P> <P>if($userlevel == "Mod"){<BR>echo "<tr><td class=text><u>Sticky:</u> "; <BR>echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";<BR>if ($topics->locked == "Yes" ){ echo" (Locked)"; } <BR>echo"</td><BR><td><BR><a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a><BR></td><BR></tr>";<BR>}</P> <P>if($userlevel == "Users"){<BR>echo "<tr><td class=text><u>Sticky:</u> "; <BR>echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";<BR>if ($topics->locked == "Yes" ){ echo" (Locked)"; } <BR>echo"</td></tr>";<BR>}<BR>}<BR>}</P> <P>$query = mysql_query("SELECT * FROM `topics` WHERE `type`='normal' ORDER BY `lastpost` DESC");<BR>while($topics=mysql_fetch_object($query)){</P> <P>if($topics->type == "normal"){</P> <P>if($userlevel == "Admin"){<BR>echo "<tr><td class=text><a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";<BR>if ($topics->locked == "Yes" ){ echo" (Locked)"; } <BR>echo"</td><BR><td><BR><a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a><BR></td><BR></tr>";<BR>}</P> <P>if($userlevel == "Head"){<BR>echo "<tr><td class=text><a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";<BR>if ($topics->locked == "Yes" ){ echo" (Locked)"; } <BR>echo"</td><BR><td><BR><a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a><BR></td><BR></tr>";<BR>}</P> <P>if($userlevel == "Mod"){<BR>echo "<tr><td class=text><a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";<BR>if ($topics->locked == "Yes" ){ echo" (Locked)"; } <BR>echo"</td><BR><td><BR><a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a><BR></td><BR></tr>";<BR>}</P> <P>if($userlevel == "Users"){<BR>echo "<tr><td class=text><a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";<BR>if ($topics->locked == "Yes" ){ echo" (Locked)"; } <BR>echo"</td></tr>";<BR>}<BR>}<BR>}</P> <P>$delete=$_GET[delete];<BR>if($delete) {</P> <P>if($userlevel == "Admin"){<BR>echo "<META HTTP-EQUIV=\"Refresh\" target=\"_top\" CONTENT=\"0; URL=forum.php\">";<BR>echo"Deleted!";<BR>mysql_query("DELETE FROM topics WHERE id='$delete'");<BR>mysql_query("DELETE FROM posts WHERE topicid='$delete'");<BR>mysql_query("INSERT INTO `staff_logs` (`username`, `action`, `date`) VALUES ('$username', 'Delete Forum Topic = $delete', '$datetime');") or die (mysql_error());</P> <P>}</P> <P>if($userlevel == "Head"){<BR>mysql_query("INSERT INTO `staff_logs` (`username`, `action`, `date`) VALUES ('$username', 'Delete Forum Topic = $delete', '$datetime') LIMIT 1;") or die (mysql_error());<BR>mysql_query("DELETE FROM topics WHERE id='$delete'");<BR>mysql_query("DELETE FROM posts WHERE topicid='$delete'");<BR>echo "<META HTTP-EQUIV=\"Refresh\" target=\"_top\" CONTENT=\"0; URL=forum.php\">";<BR>echo"Deleted!";<BR>}</P> <P>if($userlevel == "Mod"){<BR>mysql_query("INSERT INTO `staff_logs` (`username`, `action`, `date`) VALUES ('$username', 'Delete Forum Topic = $delete', '$datetime');") or die (mysql_error());<BR>mysql_query("DELETE FROM topics WHERE id='$delete'");<BR>mysql_query("DELETE FROM posts WHERE topicid='$delete'");<BR>echo "<META HTTP-EQUIV=\"Refresh\" target=\"_top\" CONTENT=\"0; URL=forum.php\">";<BR>echo"Deleted!";<BR>}</P> <P>if($userlevel == "User"){<BR>echo"Nice Try!
You Actions Have Been Logged!";<BR>mysql_query("INSERT INTO `user_logs` (`username`, `action`, `date`) VALUES ('$username', 'Delete Forum Topic = $delete', '$datetime');") <BR>or die (mysql_error());<BR>}</P> <P>}</P> <P>?></P> <P></table>


#2 NGPixel

    Senior Programmer

  • P2L Staff
  • PipPipPipPip
  • 1,410 posts
  • Gender:Male
  • Location:Montreal, Canada
  • Interests:Web Design : Coding : Animation

Posted 11 July 2007 - 02:54 PM

lol

This is just a wall of non-valid code. You can't put HTML in PHP dude...
You should learn the basics of PHP first, before trying to make a pagination script

#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 11 July 2007 - 05:22 PM

No, its not that it's invalid, its that he stole it from the wrong place.

Find and replace <BR> and <P>, and wala.
<link rel=stylesheet href=../style.css type=text/css>
<?php
include"mysql_connect.php";
include"functions.php";

$username=$_SESSION['username'];

$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));
$userlevel=$fetch->userlevel;

$topics=mysql_fetch_object(mysql_query("SELECT * FROM topics WHERE id='$username'"));

$date=gmdate('F jS Y');
$time=gmdate('g:i:s a');
$datetime="$date at $time";

?>
<form id="form" name="form" method="post" action="newtopic.php">
  <input type="submit" name="Submit" value="New Topic!" />
</form>
<table width=400 border=1 cellpadding=2 cellspacing=0 bordercolor=black class=table align=center>
  <tr>
	<td width=100% align=center class=header colspan=2>Forum</td>
	</tr>

<?php
$query = mysql_query("SELECT * FROM `topics` WHERE `type`='important' ORDER BY `lastpost` DESC");
while($topics=mysql_fetch_object($query)){

if($topics->type == "important"){

if($userlevel == "Admin"){
echo "<tr><td class=text><u><b>Important:</b></u> "; 
echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
echo"</td>
<td>
<a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
</td>
</tr>";
}

if($userlevel == "Head"){
echo "<tr><td class=text><u><b>Important:</b></u> "; 
echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
echo"</td>
<td>
<a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
</td>
</tr>";
}

if($userlevel == "Mod"){
echo "<tr><td class=text><u><b>Important:</b></u> "; 
echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
echo"</td>
<td>
<a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
</td>
</tr>";
}

if($userlevel == "Users"){
echo "<tr><td class=text><u><b>Important:</b></u> "; 
echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
echo"</td></tr>";
}
}
}

$query = mysql_query("SELECT * FROM `topics` WHERE `type`='sticky' ORDER BY `lastpost` DESC");
while($topics=mysql_fetch_object($query)){

if($topics->type == "sticky"){

if($userlevel == "Admin"){
echo "<tr><td class=text><u>Sticky:</u> "; 
echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
echo"</td>
<td>
<a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
</td>
</tr>";
}

if($userlevel == "Head"){
echo "<tr><td class=text><u>Sticky:</u> "; 
echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
echo"</td>
<td>
<a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
</td>
</tr>";
}

if($userlevel == "Mod"){
echo "<tr><td class=text><u>Sticky:</u> "; 
echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
echo"</td>
<td>
<a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
</td>
</tr>";
}

if($userlevel == "Users"){
echo "<tr><td class=text><u>Sticky:</u> "; 
echo "<a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
echo"</td></tr>";
}
}
}

$query = mysql_query("SELECT * FROM `topics` WHERE `type`='normal' ORDER BY `lastpost` DESC");
while($topics=mysql_fetch_object($query)){

if($topics->type == "normal"){

if($userlevel == "Admin"){
echo "<tr><td class=text><a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
echo"</td>
<td>
<a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
</td>
</tr>";
}

if($userlevel == "Head"){
echo "<tr><td class=text><a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
echo"</td>
<td>
<a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
</td>
</tr>";
}

if($userlevel == "Mod"){
echo "<tr><td class=text><a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
echo"</td>
<td>
<a href='topics.php?delete=$topics->id'><img src='images/delete.gif' border='0' /></a>
</td>
</tr>";
}

if($userlevel == "Users"){
echo "<tr><td class=text><a href='posts.php?topic=$topics->id' target='frameright'>$topics->topic</a>";
if ($topics->locked == "Yes" ){ echo" (Locked)"; } 
echo"</td></tr>";
}
}
}

$delete=$_GET[delete];
if($delete) {

if($userlevel == "Admin"){
echo "<META HTTP-EQUIV=\"Refresh\" target=\"_top\" CONTENT=\"0; URL=forum.php\">";
echo"Deleted!";
mysql_query("DELETE FROM topics WHERE id='$delete'");
mysql_query("DELETE FROM posts WHERE topicid='$delete'");
mysql_query("INSERT INTO `staff_logs` (`username`, `action`, `date`) VALUES ('$username', 'Delete Forum Topic = $delete', '$datetime');") or die (mysql_error());

}

if($userlevel == "Head"){
mysql_query("INSERT INTO `staff_logs` (`username`, `action`, `date`) VALUES ('$username', 'Delete Forum Topic = $delete', '$datetime') LIMIT 1;") or die (mysql_error());
mysql_query("DELETE FROM topics WHERE id='$delete'");
mysql_query("DELETE FROM posts WHERE topicid='$delete'");
echo "<META HTTP-EQUIV=\"Refresh\" target=\"_top\" CONTENT=\"0; URL=forum.php\">";
echo"Deleted!";
}

if($userlevel == "Mod"){
mysql_query("INSERT INTO `staff_logs` (`username`, `action`, `date`) VALUES ('$username', 'Delete Forum Topic = $delete', '$datetime');") or die (mysql_error());
mysql_query("DELETE FROM topics WHERE id='$delete'");
mysql_query("DELETE FROM posts WHERE topicid='$delete'");
echo "<META HTTP-EQUIV=\"Refresh\" target=\"_top\" CONTENT=\"0; URL=forum.php\">";
echo"Deleted!";
}

if($userlevel == "User"){
echo"Nice Try!
You Actions Have Been Logged!";
mysql_query("INSERT INTO `user_logs` (`username`, `action`, `date`) VALUES ('$username', 'Delete Forum Topic = $delete', '$datetime');") 
or die (mysql_error());
}

}

?>

</table>
Note, no pagination was added.

#4 birdbrain24

    Young Padawan

  • Members
  • Pip
  • 9 posts
  • Gender:Male
  • Location:Ontario, Canada
  • Interests:HTML, PHP and MySQL Coding

Posted 11 July 2007 - 09:33 PM

Take the code that rc69 posted above and add the page numbering to it please! If someone could please o that for me! And ADMIN the script works and i know the basics of php and i just don't understand know to add page numbering to my script!

#5 .CJ

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Leeds, UK

Posted 12 July 2007 - 11:15 AM

You don't learn from just asking someone to put some code on to yours, you try it yourself. Check out here http://www.pixel2life.com/tutorials/php_co...page_numbering/ and see if you can produce anything.

#6 birdbrain24

    Young Padawan

  • Members
  • Pip
  • 9 posts
  • Gender:Male
  • Location:Ontario, Canada
  • Interests:HTML, PHP and MySQL Coding

Posted 12 July 2007 - 11:25 AM

Hello ! I Tried All The Tutorails Here And I Couldn't Get Any To Work With My Script! DUH! I Wouldn't Have Asked For Help If I Could Have Done It Myself!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users