|
Posted by Rami Elomaa on 06/01/07 15:23
Akhenaten kirjoitti:
> I must be missing something rather obvious. I have the following
> snippet of code that echo's my result twice when it should be echoing
> just once (only one element in the array). What am I overlooking?
>
>
> ********************************
> $OpenQ = mysql_query("SELECT column FROM table WHERE q_uid =
> $_SESSION[userid] AND status = 1",$db); // SQL query on DB returns 1
> result
>
> $Qresult = mysql_fetch_array($OpenQ); // Fetch the array
This returns an array that has both index and associative keys. Ie. what
you get is array(0=>'something','column'=>'something');
>
> if ($_GET['OQ']) { // If the get variable is recieved
> foreach ($Qresult as $Q) {
When you loop thru the array, naturally you'll go thru both the index
and the associative key, which both point to the same value. Instead of
foreaching, you could just echo $Qresult[0] or use mysql_fetch_row or
mysql_fetch_assoc.
> echo "<br>" . $Q;
> }
> }
>
> *********************************
>
> TY.
>
--
Rami.Elomaa@gmail.com
"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Navigation:
[Reply to this message]
|