Posted by jhwrightiii on 07/21/05 00:15
I appreciate it. I am new in PHP. I knew about the result handle and
was just trying to show an example. In other languages I am able to
do something similar to that example all in one line and is what I was
aiming for. Two extra lines will do though.
Again thanks for you Help.
On Wed, 20 Jul 2005 21:06:58 -0000, gordonb.sf1ma@burditt.org (Gordon
Burditt) wrote:
>>Is it possible to set a variable from a query that will return one
>>row ie..
>>
>>$control = mysql_query("SELECT control FROM table WHERE id = '1'");
>
>Yes, but $control is a MySQL result handle, not the value.
>To get the value (and there are a number of different ways to do this,
>and you really need to do some error checking in case there was no
>row with id = 1):
>
> $r = mysql_fetch_result($control);
> $value = $r[0];
> /* we now have the value you wanted in $value */
> echo "$value";
> mysql_free_result($control);
>
> Gordon L. Burditt
>
[Back to original message]
|