Hi all ,
down you will see my code
what I want to covert the values to selected name .
means : I have these fields in form sex,agemin,agemax,nationality,contryorgin,countrystaying and status
I inserted sex,nationality,countryorgin,countrystaying,status to mysql using
drop-down box ,so all data will be in numbers for example the inserted for male in mysql 2
1)so what i want in this code when I do display data to be in name 2==converted to==> male instead of printing 2 .
2) how can I get another field is not in the form like username to be printed with each row and to be as a hayber link refre to profile.php
3) as you see there are agemin and agemax two fields for age in my sql there is only age ,,,, in this sorting form I have 2 input text boxs agemin & agemax
so there when I enter agemin as 18 & agemax as 30 ,,, will sort all people between these 2 ,,,, how can I manage it in this code.
I know lot of requests but you are the experts.
thank you in advance .
=========
<?php
include('conit.php');
include("MySQLPagedResults.class.php");
$paging_results = new MySQLPagedResults("SELECT count(*) FROM
users","page","",12,10,"<<","Previous","Next",">>"," | ");
$first_nav = $paging_results->getFirstNav();
$prev_nav = $paging_results->getPrevNav();
$next_nav = $paging_results->getNextNav();
$last_nav = $paging_results->getLastNav();
$pages_nav = $paging_results->getPagesNav();
$offset = $paging_results->currentOffset();
$results_per_page = $paging_results->results_per_page;
$current_page = $paging_results->current_page;
$total_pages = $paging_results->totalPages();
$start_number = $paging_results->getResultNumbersStart();
$end_number = $paging_results->getResultNumbersEnd();
function ee( $var )
{
return mysql_real_escape_string( $var );
}
function add_sql( $field , $var )
{
global $res;
if ( !empty( $_POST["$var"] ) ) {
if ( $_POST["$var"] != "-1" )
$res .= $field . "='" . ee( $_POST["$var"] ) . "' AND ";
}
}
$res = null;
add_sql( "sex","sex" ); // field name in the table, and $_POST variable
name
add_sql( "age", "agemax" );
add_sql( "age", "agemin" );
add_sql( "nationality", "nationality" );
add_sql( "contryorgin", "contryorgin" );
add_sql( "countrystaying", "countrystaying" );
add_sql( "status", "status" );
$fields = array( "sex" =>"sex" , "age" => "agemax" , "age" =>
"agemin","nationality" => "nationality","contryorgin" =>
"contryorgin","countrystaying" => "countrystaying","status" => "status" );
if ( !empty( $res ) ){
$Q = " WHERE " . substr( $res , 0, -4 );
}
else
$Q = "";
$res="SELECT * FROM USERS $Q LIMIT $offset,$results_per_page";
$query = mysql_query($res);
$counter = 1;
while ( $data = mysql_fetch_assoc($query) ) {
print $counter . ":
";
foreach( $fields AS $key => $value ) {
echo "$value: " . $data["$key"] . "
";
}
print "
<hr>";
$counter++;
}
echo "<p><b>Page:</b> $current_page of $total_pages |
<b>Results:</b> $start_number - $end_number<br>";
echo "$first_nav $prev_nav $pages_nav $next_nav $last_nav</p>";
?>