Not sure if its the sql query or what, but I have a pagination class and a function I am trying to put together if some one would be able to point be in the wright direction it will be very appreciated. :)

The following is the function which I am trying to get results from, based on a count of id's from a table called (profile) then joined by a row (user_id) to a table called (users) I then need to display certain rows from both tables and use the $id variable to use as an anchor so it can be used in a href link.

// Function for pagination
function get_cprofile($id = '') {
		if($id != ""):
			$id = mysql_real_escape_string($id);

			$sql = "SELECT COUNT(*) FROM profile WHERE id = '$id'";	
		$sql = "
		SELECT p.cname, p.intro, p.aimage, 
		FROM profile p INNER JOIN users u ON 
		WHERE = 'p.user_id' != '' ORDER BY ASC $pages->limit 
		$res = mysql_query($sql) or die(mysql_error());
		if(mysql_num_rows($res) != 0):
			while($num_rows = mysql_fetch_assoc($res)) {
	echo "<br />";
	$cname = $row['cname'];
	$intro = $row['intro'];
	$aimage = '<img src="members/images/'. $row['aimage'] .' " style="width:100px; height:165px; border:1px solid #000;" />';
	echo $cname;
	echo "<br />";
	echo $intro;
	echo "<br />";
	echo $aimage;
	echo "<br /><br /><hr /><br />";
    echo $pages->display_pages();  
			echo '<br /><p>No Profile Details Available! Please Add Some <-link-> </p>';
		echo '<br />';

This next bit of code calls the function above and objects class from my pagination class.

require_once 'paginator.class.php'; 
include 'class/class.php';
include 'db_inc/obj.php';

$pages = new Paginator;  
    $pages->items_total = $num_rows[0];  
    $pages->mid_range = 9;  
echo '<span style="\"margin-left:25px\""> ' . $pages->display_jump_menu() . $pages->display_items_per_page() . '</span>';  


All I seem to be getting is the result of nothing to display,

"No Profile Details Available! Please Add Some <-link->"

I just can't get my head around it, I stopped all the sql errors but now the code just seems to skip to their is nothing to display from my else: statement. :(

well I am a little confused.

For starters what is '$obj'?

also, I see that you are trying to use variables from your function in your other script and use variables from your other script in your function. Unfortunately PHP does not work this way.

from the looks of it 'get_cprofile' is not a function of a class so I would assume making a call like:


would only need to be


but the more important issue is that the variables '$pages' and '$num_rows' cannot be interchanged between the two scripts. the best way to think about it is anything inside the function is trapped there, unless you return it in the end, and anything outside the function cannot get into it, unless you pass it in as a parameter.

I hope this was helpful.

Thank you thats helped a lot I wasn't to sure if I could not use a function class inside another function. I did manage to get it working but not with a function so I will just use that instead and now I face another problem but trial and error seems the only way at the min, I now think it will be a good idea to plan this thing out on paper as im starting to loose where i am this lol, Thanks for your help very useful.

no problem, good luck. trial and error is a great way to learn.