Can anyone see where im going wrong with this code I keep hitting a brick wall with it.
Its doing my head in. I think its more the sql code, It keeps showing all data instead of just showing the data based on the user_id which should be limited to one set of data. Any help would be much appreciated :)
function get_agency_profile($id = '') {
if($id != ""):
$id = mysql_real_escape_string($id);
$sql = "
SELECT p.cname, p.email, p.work_landline, p.mobile, p.door_no, p.street, p.town, p.county, p.country,
p.postcode, p.website, p.aimage, p.intro, p.id
FROM profile p INNER JOIN users u ON u.id=p.user_id
WHERE user_id = '$id'";
else:
$sql = "
SELECT p.cname, p.email, p.work_landline, p.mobile, p.door_no, p.street, p.town, p.county, p.country,
p.postcode, p.website, p.aimage, p.intro, p.id
FROM profile p INNER JOIN users u ON u.id=p.user_id ORDER BY user_id DESC";
endif;
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) != 0):
while($row = mysql_fetch_assoc($res)) {
echo ' <br /> ';
echo ' ' . $row['id'] . ' ';
echo ' <br /> ';
echo ' ' . $row['cname'] . ' ';
echo ' <br /> ';
echo ' ' . $row['email'] . ' ';
}
else:
echo '<p>Uh Oh!, this doesn\'t exist!</p>';
endif;
}