Jump to content

[SOLVED] display multiple records from 2 tables


reece_1989

Recommended Posts

Hi,

I have two tables in a db : individual and groups

 

Individual:

T1 -is a booking ref (auto increment)

T2 -is a group ref

 

Group:

ID -is ID Number (auto increment)

name -is a group name

 

What id like to do is match T2 in individual with ID in groups to show 'name' on a php page.

 

Any ideas in the right direction would help alot!! Im completely stuck

 

My php code works in order to show everything from individual in tables in php:

<?php
$username="username";
$password="password";
$database="database";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM individual";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

?>

<table width="100%" border="2" bordercolor="#000000" cellpadding="2" cellspacing="0"  rules="rows" frame="hsides">
<tr>
<th class="style1" align="left">Booking Ref</th>
<th class="style1" align="left">Group ID</th>
<th class="style1" align="left">Group name</th>
</tr

<?
$i=0;
while ($i < $num) {

$T1=mysql_result($result,$i,"T1");
$T2=mysql_result($result,$i,"T2");
?>

<tr>
<td class="style1" width="200"><? echo $T1; ?></td>
<td class="style1" width="200"><? echo $T2; ?></td>
</tr>

<?
$i++;
}

echo "</table>";
?>

 

 

 

Thanks !!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.