I am trying to display records ...where in table 1(member1d=8) and also where (table2.itemid=table1.postid)
I am not quit sure how to get around it the right way.....
I need help. Thanks.
table 1
+--------+--------+----------+
| joinid | postid | memberid |
+--------+--------+----------+
| 1 | 3 | 8 |
| 2 | 4 | 8 |
| 3 | 5 | 8 |
| 4 | 7 | 8 |
| 5 | 10 | 8 |
+--------+--------+----------+
table 2
+----+----------+----------+---------------------+-------------------------+----
--------------------------------+
| id | itemid | posterid | postdate | title | mypost |
+----+----------+----------+---------------------+-------------------------+----
--------------------------------+
| 1 | 4 | 8 | 2009-02-23 03:06:07 | problem with my work... | am just testing to see if its ok..
|
| 2 | 9 | 7 | 2009-02-23 03:14:17 | this is for | tes ting again to see
|
| 3 | 21 | 8 | 2009-02-26 14:22:05 | it is ok? | I am having a problem
|
| 4 | 1 | 3 | 2009-02-26 22:21:03 | hi | hi
|
| 5 | 10 | 5 | 2009-02-26 22:24:20 | hi | hi
|
+----+----------+----------+---------------------+-------------------------+----
--------------------------------+
V
Php mysql help....
Moderator: General Moderators
Re: Php mysql help....
Hmm... I didn't understand you.
Are you trying to select and fetch results from your database?
If so, take a look in the code below and try to learn some 'moves'(Or you can copy paste the code, but im not sure what yuo want to display...).
Are you trying to select and fetch results from your database?
If so, take a look in the code below and try to learn some 'moves'(Or you can copy paste the code, but im not sure what yuo want to display...).
Code: Select all
$query = mysql_query('SELECT t1.*, t2.* FROM table1 t1, table2 t2');
while( $row = mysql_fetch_assoc($query) )
{
// $row['joinid'] = values of the row joinid
// $row['postid'] = values of the row postid
// etc.
echo $row['postid'];
}Re: Php mysql help....
thanks Bombas for you input... I quit learnt some new stuff.....
well this is what i want to do.
I am trying to get all "mypost etc." (on table 2) where the "memberid" (on table1) = 8 AND ( "joinid" (on table1) = "itemid" (on table2) ).
Please pardon my innitial limited explanation... i hope this one throws more light... thanks again.
table 1
+--------+--------+----------+
| joinid | postid | memberid |
+--------+--------+----------+
| 1 | 3 | 8 |
| 2 | 4 | 8 |
| 3 | 5 | 8 |
| 4 | 7 | 8 |
| 5 | 10 | 8 |
+--------+--------+----------+
table 2
+----+----------+----------+---------------------+-------------------------+----
--------------------------------+
| id | itemid | posterid | postdate | title | mypost |
+----+----------+----------+---------------------+-------------------------+----
--------------------------------+
| 1 | 4 | 8 | 2009-02-23 03:06:07 | problem with my work... | am just testing to see if its ok..
|
| 2 | 9 | 7 | 2009-02-23 03:14:17 | this is for | tes ting again to see
|
| 3 | 21 | 8 | 2009-02-26 14:22:05 | it is ok? | I am having a problem
|
| 4 | 1 | 3 | 2009-02-26 22:21:03 | hi | hi
|
| 5 | 10 | 5 | 2009-02-26 22:24:20 | hi | hi
|
+----+----------+----------+---------------------+-------------------------+----
--------------------------------+
well this is what i want to do.
I am trying to get all "mypost etc." (on table 2) where the "memberid" (on table1) = 8 AND ( "joinid" (on table1) = "itemid" (on table2) ).
Please pardon my innitial limited explanation... i hope this one throws more light... thanks again.
table 1
+--------+--------+----------+
| joinid | postid | memberid |
+--------+--------+----------+
| 1 | 3 | 8 |
| 2 | 4 | 8 |
| 3 | 5 | 8 |
| 4 | 7 | 8 |
| 5 | 10 | 8 |
+--------+--------+----------+
table 2
+----+----------+----------+---------------------+-------------------------+----
--------------------------------+
| id | itemid | posterid | postdate | title | mypost |
+----+----------+----------+---------------------+-------------------------+----
--------------------------------+
| 1 | 4 | 8 | 2009-02-23 03:06:07 | problem with my work... | am just testing to see if its ok..
|
| 2 | 9 | 7 | 2009-02-23 03:14:17 | this is for | tes ting again to see
|
| 3 | 21 | 8 | 2009-02-26 14:22:05 | it is ok? | I am having a problem
|
| 4 | 1 | 3 | 2009-02-26 22:21:03 | hi | hi
|
| 5 | 10 | 5 | 2009-02-26 22:24:20 | hi | hi
|
+----+----------+----------+---------------------+-------------------------+----
--------------------------------+