Re: mysql query

From: Date: Wed, 11 Sep 2002 14:36:10 +0000
Subject: Re: mysql query
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-115993@lists.php.net to get a copy of this message
Ooops, for clarity, I shouldn't have named the result of the function "row" but "euro". It should be: $euro=mysql_one_element("select euro from brandstofprijzen where id=2", "euro"); Bill wrote: > function mysql_one_element($query, $element) { > // quickly returns just one element from a query > $one=mysql_query($query); > // add error checking here if you wish > $r=mysql_fetch_array($one); > $thisvalue=$r[$element]; > return($thisvalue); > } > > $row=mysql_one_element("select euro from brandstofprijzen where id=2", > "euro"); > > Chris Schoeman wrote: > > > I use the script below to get one value out of a database: > > > > $result = mysql_query("select euro from brandstofprijzen where id=2") > > or die (mysql_error()); > > while ($row = mysql_fetch_array($result)) > > { > > $euro = $row["euro"]; > > } > > mysql_free_result($result); > > > > This is working fine, but is there an easier (less code) way to do > > this? > > > > Thankx

« previous php.general (#115993) next »