Jump to content

Displaying Info From 2 Tables


bamfon

Recommended Posts

Not good at explaning myself but I will try :P

 

 

$con = database_connect();
$sqs="SELECT *
FROM `11game`.`army_info`
LEFT JOIN `11game`.`armyinbase`
ON ( `army_info`.`type` = `armyinbase`.`type` )" ;

$res1=mysql_query($sqs,$con);
if(!$res1)
{
die('error in data'.mysql_error());

}
?>

while($row1=mysql_fetch_assoc($res1))
{



$name=$row1['name'];
$info=$row1['info'];


?>

$result2 = mysql_query($sql2)or exit(mysql_error());
while($row2 = mysql_fetch_array($result2))
{
$total = $row1['total'];




}






<td height="14" align="center"><?php echo $row1['name'];?></td>

<td height="30" rowspan="2" align="center"> <?php echo $total ?></td>
<td rowspan="2"> </td>
<td rowspan="2">1</td>
</tr>
<tr>
<td height="14" align="center"><?php echo $info ;?></td>
</tr>
<?php
}
?>

 

What I am trying to do Is

 

 

The first table to recall up the the info and place it in the table (done that part its working )

But I was the 2nd table to recall up info and add it in the right place EG on the line where ID =1 on both tables

 

 

What should be shown is something like this

 

 

 

 

Table

 

Troops How many you own cost per a unit

tank 2 10gold

 

 

 

The troops and cost per a unit is from table one while the how many you own is from table 2

 

Right now its showing info info from table 1 how many times there are rows intable 2

Link to comment
https://forums.phpfreaks.com/topic/270927-displaying-info-from-2-tables/
Share on other sites

That's not all the code, where is the content of $sql2?

Your code here :-

$sqs="SELECT * FROM `11game`.`army_info` LEFT JOIN `11game`.`armyinbase` ON ( `army_info`.`type` = `armyinbase`.`type` )" ; 

looks close to what I imagine you would want to be using to get the results you are looking for, but I'd like to see the full and actual table structures if you could.

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.