Page 1 of 1

Next Page & Validate Field

Posted: Sun Sep 16, 2012 2:42 am
by Ghoz
Hi,
How to make the next & previous page? The code below is to search for user. How to validate it so that we can't left the field empty? Then how to make the next & previous page? For example to display 10 results per page?
Thanks!

Code: Select all

<?php 
// This will allow to use the css inside includes if editing this file directly... probably
$visitingfiledirectly = false;
if($visitingfiledirectly)
{
	?>
    <link rel="stylesheet" type="text/css" media="screen" href="../stylus.css">
    <?php
}

?>
<b>Search Result</b><br />
<div class="searchlist">
<?php
$uname = "";
if(isset($_POST["u"]) && !empty($_POST["u"]) && strlen($_POST["u"]) > 0)
{
	$uname = PHP_slashes($_POST["u"]);
}
						$result2 = mysql_query("SELECT Avatar, Name, Username, LastLoginDate, Email FROM users where Name Like '%".$uname."%'ORDER BY Name ASC");
//where Name Like (search for 'Name')
//ORDER BY Name ASC (Order by 'Name' ascending)
//You can add this for extra function - ORDER BY Name,Email ASC

if(mysql_num_rows($result2) > 0)
{
						?>
<table border = "1" width="100%">
<tr>
<td></td> 
<td><b><p align="center">Name</b></td>
<?php
	if($admin >= 1)
	{
		?>
		<td><b><p align="center"><p align="center">Email Address</b></td>
		<?php
	}				
?>
<td><b><p align="center">Last Login</b></td>
</tr>
                        <?php
while ($row2 = mysql_fetch_row($result2)){
?>
<tr>
<td><p align="center"><?php useLightbox($row2[0],$row2[1],50,50);?></td>
<td><p align="center"><a target="_blank" href="index.php?section=profile&uid=<?php echo getUserId($row2[2]);?>"><b><?php echo $row2[1];?></b></a></td>
<!---$row2[1] is the name--->
<?php
if($admin >= 1)
	{
		?><td><p align="center"><?php echo $row2[4];?></td><?php
	}	
?><td><p align="center"><?php echo referencialHour($row2[3]);?></td> 
</tr><?php
  }
  
?>
</table>
</div>
<?php
}
else
{
?>

<div class="searchuser">

<font color="#FF0000"><b>No User found!</b></font>
<?php
}

?>

Re: Next Page & Validate Field

Posted: Sun Sep 16, 2012 6:16 am
by social_experiment
viewtopic.php?f=1&t=135353&p=675608&hil ... on#p675469
In this post is a link to some pagination tutorials;
Ghoz wrote:How to validate it so that we can't left the field empty?
Client-side validation + server side validation. Note that even with both these options in place a user can still submit an empty field by disabling javascript on their browser so you need a php (server side) solution.