This list is for discussing issues that relate to the development of the PHP
language.  For mailing lists that discuss development with PHP, see
www.php.net/support.php

Also, even though [0] and ['id'] initially contain the same value, they are
not bound together in any way.  You may be able to accomplish what you
desire by using references. (See the manual section on references for more
information.

ie.  $q->data[0]["id"] =& $q->data[0][0];

--zak

----- Original Message -----
From: "Marc Boeren" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 09, 2001 2:37 AM
Subject: [PHP-DEV] how-to get array[0] and array["name"] to actually
reference only 1 value?


>
> What I'm trying to do is get the following php-script to work... (the only
> thing about this that doesn't work is in the fourth 'echo' line...)
>
> $db = dbx_connect("mysql", "localhost", "username", "password"); // works
> $result = dbx_query($db, "use dbname"); // works
> $q = dbx_query($db, "select id from tbl"); // works
>
> // now I have the results in a 2D array, q->data[row][col]
> // where col can be either an index or a fieldname
> echo $q->data[0][0]; // works, displays first returned id, say 17
> echo $q->data[0]["id"]; // works, displays first returned id (17)
>
> // now I want to change the first returned id...
> $q->data[0][0] = 12345;
>
> // what I want is that the next two lines BOTH reflect the change
> echo $q->data[0][0]; // works, displays changed id (12345)
> echo $q->data[0]["id"]; // doesn't work like I would like, still displays
> first returned id (17)
>
> // This is the same behaviour that you get when you use the
mysql-functions
> // directly, so no help there... (you can still combine these functions
with
> the
> // mysql-functions, if needed, like
> $fieldtype = mysql_field_type($q->handle, 0);
> // )
>
> $result = dbx_close($db); // works ( $result = mysql_close($db->handle);
> works too, BTW )
>
>
> Currently I don't think this can be done the way I would like it to work.
> Can anybody contradict me on this?
>
> Cheerio, Marc.
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to