PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
kpraman
Forum Contributor
Posts: 172 Joined: Fri Oct 13, 2006 10:54 am
Post
by kpraman » Fri Jan 05, 2007 7:30 am
Hello,
Code: Select all
$query=mysql_query("SELECT * FROM categories,events,story");
while($r=mysql_fetch_array($query))
{
$catId[]=$r['categoryId'];
}
print_r($catId);
The categories contains categoryId field , two rows have been populated. I am getting,
Code: Select all
Array ( [0] => 1 [1] => 2 [2] => 1 [3] => 2 [4] => 1 [5] => 2 [6] => 1 [7] => 2 [8] => 1 [9] => 2 [10] => 1 [11] => 2 [12] => 1 [13] => 2 [14] => 1 [15] => 2 [16] => 1 [17] => 2 [18] => 1 [19] => 2 [20] => 1 [21] => 2 [22] => 1 [23] => 2 [24] => 1 [25] => 2 [26] => 1 [27] => 2 [28] => 1 [29] => 2 [30] => 1 [31] => 2 )
I should get,
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Fri Jan 05, 2007 7:53 am
If you only want the two entries from one table why do you use a join with another table?
xpgeek
Forum Contributor
Posts: 146 Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:
Post
by xpgeek » Fri Jan 05, 2007 2:00 pm
kpraman wrote: Hello,
Code: Select all
$query=mysql_query("SELECT * FROM categories,events,story");
while($r=mysql_fetch_array($query))
{
$catId[]=$r['categoryId'];
}
print_r($catId);
try this
[sql]
SELECT * FROM categories,events,story LIMIT 2
[/sql]
kpraman
Forum Contributor
Posts: 172 Joined: Fri Oct 13, 2006 10:54 am
Post
by kpraman » Sat Jan 06, 2007 6:21 pm
Volka, in the while loop i'll be fetching other fields also from table2 and table3