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'";
else:
$sql = "
SELECT p.cname, p.intro, p.aimage, p.id
FROM profile p INNER JOIN users u ON u.id=p.user_id
WHERE u.id = 'p.user_id' != '' ORDER BY p.id ASC $pages->limit
";
endif;
$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();
}
else:
echo '<br /><p>No Profile Details Available! Please Add Some <-link-> </p>';
endif;
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;
$pages->paginate();
echo '<span style="\"margin-left:25px\""> ' . $pages->display_jump_menu() . $pages->display_items_per_page() . '</span>';
if(isset($_GET['id'])):
$obj->get_cprofile($_GET['id']);
else:
$obj->get_cprofile();
endif;
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. :(