Forum Moderators: coopster

Message Too Old, No Replies

Joining 2 tables and echoing a value

         

asson

11:32 am on Oct 5, 2008 (gmt 0)

10+ Year Member



Hi,
I'm a PHP newbie.

I need a little help with echoing a value by joining 2 tables.

Table 1 has these fields,
id, name, username

Table2,
id, subject, short, and username.

The username in table2 = username @ table1.

I want to join those 2 tables and echoing value in the name field inside table1.


$query_nameu = "SELECT table1.username, table2.username ".
"FROM table1, table2 ".
"WHERE table1.username = table2.username";

$result = mysql_query($query_nameu) or die(mysql_error());

Anything like this?
<?php echo $query_nameu['name']; ?>

Thanks in advance.

asson

12:41 pm on Oct 5, 2008 (gmt 0)

10+ Year Member



Fixed it, thanks anyway.

asson

1:04 pm on Oct 5, 2008 (gmt 0)

10+ Year Member



sorry for updating the same thread.
How to make them work dynamicly, I show that name with articles, and I want to each article gets it's name value based on username value?