开发者

How to assign a MySQL statement to a PHP variable

I have looked all over the web and cannot seem to find a proper way to assign the result of a MySQL query to a PHP variable. The code开发者_StackOverflow社区 that I currently have returns a "resource id #3" error. Here is what it looks like.

//Select the 'aQID' of the question that has it's BOOL set to "true"

$currentQ = mysql_query("SELECT aQID FROM approvedQuestions WHERE status='1'");

$cuQ = mysql_result($currentQ,1,"status");

echo $cuQ;

I know that the query will only ever return one record (the active question). But I cannot seem to figure out what function to use.


$currentQ = mysql_query("SELECT aQID FROM approvedQuestions WHERE status='1'");

    $rs = mysql_fetch_array($currentQ);

    var_dump($rs);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜