<? php code limit result & next page?

Just_DO_it

New member
I have this code is created by parse error I need to add 3 things (i tried but can not get it .

1-to limit result in one page for 10 rows
2- create next & pev links for more rows to be in next pages
if i get 20 rows or result 10 will be in first page and the rest in next page and i will move using next.

3- the three fields am calling from my table are country ,gender ,name
and country is entered to my sql as numbers not text because I inserted countries by drop-down box ,,,, for example USA will be in my sql as 2 , France 3 and so on ....same gender : female :1 & male :2

so I want methods when I call these numbers will printed in my page as name
2==> USA
3==> France

here the cod":

<?php
include( "connect.php" );

function ee( $var )
{
return mysql_real_escape_string( $var );
}

function add_sql( $field , $var )
{
global $sql;
if ( !empty( $_POST["$var"] ) ) {
if ( $_POST["$var"] != "All" )
$sql .= $field . "='" . ee( $_POST["$var"] ) . "' AND ";
}
}

$sql = null;

add_sql( "city", "city" ); // field name in the table, and $_POST variable name
add_sql( "county", "county" );
add_sql( "gender", "gender" );

$fields = array( "city" => "City" , "county" => "Country" , "gender" => "Gender" );

if ( !empty( $sql ) )
$Q = " WHERE " . substr( $sql , 0, -4 );
else
$Q = "";
$query = "SELECT * FROM users " . $Q;

$res = mysql_query( $query );
$counter = 1;
while ( $list = mysql_fetch_assoc( $res ) ) {
print $counter . ":
";
foreach( $fields AS $key => $value ) {
echo "$value: " . $list["$key"] . "
";
}

print "
<hr>";
$counter++;
}

?>

the result should be

SAM

Male

USA

not

SAM

2

2

thanks in advance
 
Back
Top