为sql搜索查询分配值

时间:2014-01-27 18:54:25

标签: php sql

我正在为社交网站建立一个积分系统。我希望为用户持有的不同程度分配多个点。我已经弄清楚如何访问数据库并确定用户是否确实拥有学位,但我不确定如何实际编写一个代码来为搜索结果提供一个点值。这是我到目前为止,请告知:

$assoc = mysqli_query ($con, "SELECT * FROM jos_social_fields_data WHERE uid = '" . Foundry::user()->id . "' AND (data = 'ASSOCIATES' OR data = 'ASSOCIATES1' OR data = 'ASSOCIATES2'");

while ($row = mysqli_fetch_assoc($assoc))
{
**return //value = 0.5;** <---This is the part where I am not sure how to give a value to the search results. I would like them to earn a half of a point for holding this degree type.
}

$bach = mysqli_query ($con, "SELECT * FROM jos_social_fields_data WHERE uid = '" . Foundry::user()->id . "' AND (data = 'BACHELORS' OR data = 'BACHELORS1' OR data = 'BACHELORS2'");

while ($row = mysqli_fetch_assoc($bach))
{
**return //value = 1.0;** <---This is the part where I am not sure how to give a value to the search results. I would like them to earn one point for holding this degree type.
}

0 个答案:

没有答案