Home     Articles & Projects     Products & Web Services     Forum

Value from database

Hi i am trying to do the following PHP

I want to get the value row from the field_id which = 35 and the user_id = $usid

The DB looks like this
id | user_id | field_id | value
3 63 35 russellharrower
4 53 35

if the user has no value i want to show an error message like
please update your profile.

if the user has a value i want it to print out the value.

$sql = "SELECT `value` FROM `jos_community_fields_values` WHERE `field_id` = 35 AND `user_id` = $usid";
$query = mysql_query($sql);
$sign = mysql_result($query);
print $sign;

Hi Russell, Something like

Hi Russell,

Something like this should do the trick;

$sql = "SELECT `value` FROM `jos_community_fields_values` WHERE `field_id` = 35 AND `user_id` = $usid";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
if ($row["value"])
{
  print "Value is ".$row["value"];
}
else
{
  print "Please update your profile!";
}

Cheers!
David.