For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > February 2005 > Two tables combining









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Two tables combining
RotterdamStudents

2005-02-20, 8:55 am

Hi all,

i'm trying to combine stuff from table a and table b in one page. I tried
something with array_combine but it didn't work.

Can someone help me out with the necessary piece of code ??

Thanx

Martijn


windandwaves

2005-02-20, 8:55 am


"RotterdamStudents" <NOSPAMnewsNOSPAM@MAPSONcistron.nederland> wrote in message news:cv9sas$9sq$1@news.cistron.nl...
> Hi all,
>
> i'm trying to combine stuff from table a and table b in one page. I tried
> something with array_combine but it didn't work.
>
> Can someone help me out with the necessary piece of code ??
>
> Thanx
>
> Martijn
>
>


Hoi Martijn

Try Union, at least if you are using MySql

http://dev.mysql.com/doc/mysql/en/union.html

Groet

- Nicolaas


Armando Padilla

2005-02-20, 3:55 pm

windandwaves wrote:
> "RotterdamStudents" <NOSPAMnewsNOSPAM@MAPSONcistron.nederland> wrote in message news:cv9sas$9sq$1@news.cistron.nl...
>
>
>
> Hoi Martijn
>
> Try Union, at least if you are using MySql
>
> http://dev.mysql.com/doc/mysql/en/union.html
>
> Groet
>
> - Nicolaas
>
>

Hey

SELECT * FROM TABLE_A, TABLE_B WHERE TABLEA.SOMEID = TABLE_B.SOMEID

or

SELECT * FROM TABLE_A INNER JOIN TABLE_B ON TABLE_A.SOMEID = TABLE_B.SOMEID

no if you want to pass all that info into an array so you can hadle it
later do the below.


$array = array();
$i = 0;
while($getInfo = mysql_fetch_array($RESULTS)){

for($j=0; $j<mysql_num_fields($RESULTS); $j++ ){
$array[$i][$j] = $getInfo[$j];
}

$i++;
}

the above code returns a multidimensional array with all the info that
we received from the database.

Hope that helps
Armando Padilla
http://www.armando.ws
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com