When you use mysql_fetch_object(), you get back an object. $object->property
access a field.
When you use mysql_fetch_array(), you get back an array. $array[index]
access the same field.

If you'd like, replace mysql_fetch_object with mysql_fetch_array, and use
the syntax $row["user_id"].  Either one will work.

It should be in the manual under www.php.net/mysql

-Ben

-----Original Message-----
From: SED [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 16, 2001 6:19 PM
To: [EMAIL PROTECTED]
Subject: [PHP] $row->user_id;


Thanks! Tell me though, what does the following mean or should I ask how
does it work?

        $row->user_id;

Is it somehow relate to the following?

        $row["user_id"];

I tried to look for this in the manual but without any luck... perhaps I'm
going blind ;)

SED

-----Original Message-----
From: Benjamin Munoz [mailto:[EMAIL PROTECTED]]
Sent: 17. janúar 2001 01:46
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: [PHP] MySQL - How to transfer a query resault into a
variable?



http://www.php.net/manual/en/function.mysql-fetch-object.php

Modified example from the manual above...

<?php
mysql_connect ($host, $user, $password);
$result = mysql_db_query ("database", "select * from table");
while ($row = mysql_fetch_object ($result)) {
        // save database fields into variables here
        $user_id = $row->user_id;
        $name = $row->name;
        // print them out if you want, or store them in an array to return
if this is a function
        print ("<a href=user_details.php?user_id=$user_id>$name</a><br>\n");
}
mysql_free_result ($result);
?>

-Ben



-----Original Message-----
From: SED [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 16, 2001 5:21 PM
To: [EMAIL PROTECTED]
Subject: [PHP] MySQL - How to transfer a query resault into a variable?


Hi,

Lets say I have columns e.g.

        | name | address | phone |

I want to make a list of all the names and put the result into a HTML page
where each name is a link.

When the name is clicked (the link), it will open another HTML page with
full information (name, address and phone).

I know how to send the query to list the names (and into a formatted
HTML-file), but I don't know how to put each name into a variable or a link
for the next step.

Can you point me to functions I should focus at or even a solution?

Regards,
Sumarlidi Einar Dadason

SED - Graphic Design

------------------------------------------
Phone:       (+354) 4615501
Mobile:      (+354) 8960376
Fax:         (+354) 4615503
E-mail:      [EMAIL PROTECTED]
Homepage:    www.sed.is <- New Homepage!
------------------------------------------


--
PHP General 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 General 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 General 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 General 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