<? PHP little adjust?

Just_DO_it

New member
I need just little adjust in my code so it will work fine dont know how to do it

first see my cod before update

PHP:
<?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("username","-1");
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>"; 




?>



the output will look like

1-username:SAM sex:male nationality:USA age:30 .....
2-username:John sex:male nationality: USA age :31


but after I inserted this to my code "the part between two lines =="


PHP:
$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"]. "
";

}



==================================
==================================
while($row = mysql_fetch_array($query)) {

$id = $row['ID'];
$user = $row['username'];


echo "<a href='profile.php?id=$id'>$user</a>";

================================
================================

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>";




?>


the output collapse on each other
looks like

1-username :SAM sex:male nationlity :USA age :30
johnsarasamsmithteracarlosmithcarl .....

giving me only one result and down users names gathering inside each other.

how to adjust ?

why am inserting the second code because I want when I have result username show as link when I click on it will take me to SAM information for example .





thanks in advance
 
Back
Top