Jump to content


Displaying Info From 2 Tables

  • Please log in to reply
1 reply to this topic

#1 bamfon


    Advanced Member

  • Members
  • PipPipPip
  • 82 posts

Posted 20 November 2012 - 01:13 AM

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` )" ;

die('error in data'.mysql_error());





$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">&nbsp;</td>
<td rowspan="2">1</td>
<td height="14" align="center"><?php echo $info ;?></td>

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


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

Edited by bamfon, 20 November 2012 - 01:14 AM.

#2 Muddy_Funster


    Advanced Member

  • Members
  • PipPipPip
  • 3,383 posts

Posted 20 November 2012 - 09:42 AM

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.

Please: "This doesn't work..." is not a question.  We're not the government: we don't have anything to view what your doing on your computer.  Help us help you by asking a good question.


"Things needed to ask a "good" question:

  • A description of the context of your issue (Optional but can be a huge help in certain circumstances)
  • What is the actual problem (Mandatory)
  • What does the code actually do (Mandatory)
  • What you think the code should do / What you want the code to do (Mandatory)
  • What things have you tried so far (Optional, but missing it out just wastes your time and ours)
  • The actual code as you are running it - minus any personal information like Database Login Credentials (Mandatory - don't just post pseudo, the vast majority of issues are syntax and not logic)
  • As much info about your development environment as you can give - even if it's just letting us know you are using a hosting provider instead of a local install (Optional, but some questions can not be answered without it.)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users