Multiple pages PHP how????

Posted by sandy on Stack Overflow See other posts from Stack Overflow or by sandy
Published on 2010-03-29T16:47:40Z Indexed on 2010/03/29 16:53 UTC
Read the original article Hit count: 413

Filed under:
|
|

Here I have a problem in this code ..

I want to specify the 4 values in each page .. But I can not ... So far there is a problem, I think, in limit

<?php 

if(!isset($_GET["page"])) 
{ 
$page=1; 


include ("connect.php");  
} 
else 
{ 
$page= intval($_GET['page']); 
} 
$max=4; 
$from=($max*$page)- $max; 
$sql = mysql_query("select * from uploads,members,rooms where uploads.MemberID = members.MemberID and uploads.RoomID = rooms.RoomID and UploadCategory='L' order by UploadID desc limit $from,$max  ");  
$num_sql = mysql_num_rows($sql); 

?> 


<table width="400" border="0" cellspacing="1" cellpadding="0"> 
<tr> 
<td><form name="form1" method="post" action=""> 
<div align="center"> 
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> 
<tr> 
<td bgcolor="#FFFFFF">&nbsp;</td> 
<td colspan="4" bgcolor="#FFFFFF"> 
<p align="center"><font size="4"> file</font></td> 
</tr> 
<tr> 
<td align="center" bgcolor="#FFFFFF">#</td> 

<td align="center" bgcolor="#FFFFFF"><strong>member</strong></td> 

<td align="center" bgcolor="#FFFFFF"><strong> Name</strong></td> 

</tr> 
</div> 

<?php 


//$sql1 = mysql_query("select * from book order by id desc limit $from,$max "); 
//$num_sql1 = mysql_num_rows($sql1); 
$pages=ceil($num_sql/$max); 
$num = mysql_num_rows($sql); 
//$result = mysql_query("SELECT * FROM book order by id"); 

while($row = mysql_fetch_array($sql)) 


  { 

     ?> 




<tr> 
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['UploadID']; ?>"></td> 
<td bgcolor="#FFFFFF"> <?php echo $row[MemberName]. "<br />";  ?></td> 


<td bgcolor="#FFFFFF"> <?php echo $row[UpoadName]."<br />";  ?></td> 



</tr> 

<?php 

} 

?> 

<tr> 
<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="delete"></td> 
</tr> 


<?php 


if($page>1) 
{ 
$prev=$page-1; 
echo"<a href=".$PHP_SELF."?page=$prev\"></a>"; 
} 
for($i=1;$i<=$pages;$i++) 
{ 
if($page==$i) echo" [$i] "; 
else 
{ 
echo" <a href=".$PHP_SELF."?page=$i\">$i</a> "; 
} 
} 
if($page<$pages) 
{ 
$next=$page+1; 
echo"<a href=".$PHP_SELF."?page=$next\"></a>"; 
} 
 ?> 


</html> 

thanks alote

© Stack Overflow or respective owner

Related posts about multiple

Related posts about pages