Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8023645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:37:17+00:00 2026-06-04T22:37:17+00:00

I this codes to join two tables in my database. It didn’t show any

  • 0

I this codes to join two tables in my database. It didn’t show any error message when trying to echo it using while loop, but also it shows nothing. Can anyone help me please?

$sql = "SELECT * FROM usr_details, paymnt_details WHERE usr_details.Trnsnubr = paymnt_details.Trnsnubr";

$sql = 
"SELECT *
FROM usr_details 
JOIN paymnt_details ON usr_details.Trnsnubr = paymnt_details.Trnsnubr";  

This is my html and PHP code for echoing:

$rs_result = mysql_query ($sql) or die(mysql_error()); 
<table width="100%" height="109" border="1" cellpadding="2px" >
  <tr>
    <td colspan="5" class="mainheader">Registerd Persons</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="16"></td>
  </tr>
 <tr>
    <td class="tableheader" width="68">Payment</td>
    <td class="tableheader" width="64">Amount</td>
    <td class="tableheader" width="58">Date</td>
    <td class="tableheader" width="74">Trnsnubr</td>
    <td class="tableheader" width="97"> Paymenttyp </td>
    <td class="tableheader" width="59">Room Type</td>
    <td class="tableheader" width="96"> Packgname </td>
    <td class="tableheader" width="142">Full name</td>
    <td class="tableheader" width="1"> Email </td>
    <td class="tableheader" width="1">Mobile </td>
    <td class="tableheader" width="1">Address</td>
    <td class="tableheader" width="1">Country</td>
    <td class="tableheader" width="40">Mem_num</td>
    <td class="tableheader" width="40">Chptr</td>
    <td class="tableheader" width="40">Ral</td>
    <td class="tableheader" width="40">ex-mem-1-name</td>
    <td class="tableheader" width="40">ex-mem-2-name</td>
    <td class="tableheader" width="40">Faly-mem-1-name</td>
    <td class="tableheader" width="40">Faly-mem-2-name</td>
    </tr>
<?php 
while ($row = mysql_fetch_assoc($rs_result)) { 
$amount=$row["amount"];
$successness=$row["successness"];
$Timestamp=$row["Timestamp"];
$fname=$row["fname"];
$lname=$row["lname"];
$memnumbr=$row["memnumbr"];
$chptrpostion=$row["chptrpostion"];
$ralpositin=$row["ralpositin"];
$adrs1=$row["adrs1"];
$adrs2=$row["adrs2"];
$city=$row["city"];
$cntry=$row["cntry"];
$MTelNo=$row["MTelNo"];
$email=$row["email"];
$Trnsnubr=$row["Trnsnubr"];
$packgname=$row["packgname"];
$rtype=$row["rtype"];
$paymenttyp=$row["paymenttyp"];
$exmem1name=$row["exmem1name"];
$exmem2name=$row["exmem2name"];
$familymem1name=$row["familymem1name"];
$familymem2name=$row["familymem2name"];


        ?> 
<tr>
<td>  dfgdfgfdgdfgdg<?php echo $successness;?></td>
<td> <?php echo $amount;?></td>
<td> <?php echo $Timestamp;?></td>
<td> <?php echo $Trnsnubr;?></td>
<td> <?php echo $paymenttyp;?></td>
<td> <?php echo $rtype;?></td>
<td> <?php echo $packgname;?></td>
<td> <?php echo $fname." ".$lname;?></td>
<td> <?php echo $email;?></td>
<td> <?php echo $MTelNo;?></td>
<td> <?php echo $adrs1." ".$adrs2." ".$city;?></td>
<td> <?php echo $cntry;?></td>
<td> <?php echo $memnumbr;?></td>
<td> <?php echo $chptrpostion;?></td>
<td> <?php echo $ralpositin;?></td>
<td> <?php echo $exmem1name;?></td>
<td> <?php echo $exmem2name;?></td>
<td> <?php echo $familymem1name;?></td>
<td> <?php echo $familymem2name;?></td>
</tr>
<?php 
}; 
?> 
</table>

This is my whole coding file:

<?php session_start();
$user_name = $_SESSION['username'];
$user_pass = $_SESSION['password'];
if ( $user_name == '' ) {
header('location:login.php');
exit();
 }
?>
<?php require_once('connection.php'); ?>
<?php require_once('function.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/main.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/users.css" rel="stylesheet" type="text/css" media="all" />
<link href="../dojo/dojo/resources/dojo.css" type="text/css" media="all" />
<link href="../dojo/dijit/themes/nihilo/nihilo.css" type="text/css" media="all" />
<script type="text/javascript" src="../dojo/dojo/dojo.js" ></script>
<script src="js/navigation.js" type="text/javascript"></script>
<script type="text/javascript">

</script>
<style type="text/css">
.tableheader {
    font-size: 18px;
    font-weight: bold;
    color: #96C;
}
.mainheader {
    font-size: 24px;
    font-weight: bolder;
    color: #09F;
}
</style></head>

<body class="nihilo">
<span class="tableheader"></span>
<div id="wrap">
<!-- Enable when Ajax is loading -->
<div id="loading_wrap"></div>
<div id="loading"><img src="images/loading.gif" width="32" height="32" alt="loading" /><br />Loading...</div>
<!-- End loading  -->
  <div id="head">
    <div id="subHead"></div>
  </div>
  <div id="main">
<?php 
if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }; 
$limit= 5;
$start_from = ($page-1) * $limit; 
//$sql = "SELECT * FROM usr_details ORDER BY Trnsnubr ASC LIMIT $start_from, $limit "; 
//$sql = "SELECT * FROM usr_details, paymnt_details WHERE usr_details.Trnsnubr = paymnt_details.Trnsnubr";
/*$sql = 
"SELECT *
FROM usr_details 
JOIN paymnt_details ON usr_details.Trnsnubr = paymnt_details.Trnsnubr";*/
$sql = "SELECT usr_details.*, paymnt_details.amount, paymnt_details.successness
FROM usr_details 
JOIN paymnt_details ON usr_details.Trnsnubr = paymnt_details.Trnsnubr";
$rs_result = mysql_query ($sql) or die(mysql_error()); 
?> 
<table width="100%" height="109" border="1" cellpadding="2px" >
  <tr>
    <td colspan="5" class="mainheader">Registerd Persons</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="16"></td>
  </tr>
 <tr>
    <td class="tableheader" width="68">Payment</td>
    <td class="tableheader" width="64">Amount</td>
    <td class="tableheader" width="58">Date</td>
    <td class="tableheader" width="74">Trnsnubr</td>
    <td class="tableheader" width="97"> Paymenttyp </td>
    <td class="tableheader" width="59">Room Type</td>
    <td class="tableheader" width="96"> Packgname </td>
    <td class="tableheader" width="142">Full name</td>
    <td class="tableheader" width="1"> Email </td>
    <td class="tableheader" width="1">Mobile </td>
    <td class="tableheader" width="1">Address</td>
    <td class="tableheader" width="1">Country</td>
    <td class="tableheader" width="40">Mem_num</td>
    <td class="tableheader" width="40">Chptr</td>
    <td class="tableheader" width="40">Ral</td>
    <td class="tableheader" width="40">ex-mem-1-name</td>
    <td class="tableheader" width="40">ex-mem-2-name</td>
    <td class="tableheader" width="40">Faly-mem-1-name</td>
    <td class="tableheader" width="40">Faly-mem-2-name</td>
    </tr>
<?php 
while ($row = mysql_fetch_assoc($rs_result)) { 
$amount=$row["amount"];
$successness=$row["successness"];
$Timestamp=$row["Timestamp"];
$fname=$row["fname"];
$lname=$row["lname"];
$memnumbr=$row["memnumbr"];
$chptrpostion=$row["chptrpostion"];
$ralpositin=$row["ralpositin"];
$adrs1=$row["adrs1"];
$adrs2=$row["adrs2"];
$city=$row["city"];
$cntry=$row["cntry"];
$MTelNo=$row["MTelNo"];
$email=$row["email"];
$Trnsnubr=$row["Trnsnubr"];
$packgname=$row["packgname"];
$rtype=$row["rtype"];
$paymenttyp=$row["paymenttyp"];
$exmem1name=$row["exmem1name"];
$exmem2name=$row["exmem2name"];
$familymem1name=$row["familymem1name"];
$familymem2name=$row["familymem2name"];
?> 
<tr>
<td> <?php echo $successness;?></td>
<td> <?php echo $amount;?></td>
<td> <?php echo $Timestamp;?></td>
<td> <?php echo $Trnsnubr;?></td>
<td> <?php echo $paymenttyp;?></td>
<td> <?php echo $rtype;?></td>
<td> <?php echo $packgname;?></td>
<td> <?php echo $fname." ".$lname;?></td>
<td> <?php echo $email;?></td>
<td> <?php echo $MTelNo;?></td>
<td> <?php echo $adrs1." ".$adrs2." ".$city;?></td>
<td> <?php echo $cntry;?></td>
<td> <?php echo $memnumbr;?></td>
<td> <?php echo $chptrpostion;?></td>
<td> <?php echo $ralpositin;?></td>
<td> <?php echo $exmem1name;?></td>
<td> <?php echo $exmem2name;?></td>
<td> <?php echo $familymem1name;?></td>
<td> <?php echo $familymem2name;?></td>
</tr>
<?php 
}; 
?> 
</table>

</div>
 <div id="footer">
<?php include("footer.php"); ?>
 </div>
</div> 
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:37:18+00:00Added an answer on June 4, 2026 at 10:37 pm

    If these tables have columns with the same name this request will cause an error. It’s happens coz you tried get all values by column name. try to not use * in difficult queries.

    Try do like this:

    SELECT usr_details.*, paymnt_details.field1, paymnt_details.field2
    FROM usr_details 
    JOIN paymnt_details ON usr_details.Trnsnubr = paymnt_details.Trnsnubr
    

    1

    <?
    $res = mysql_query("SELECT * FROM usr_details LIMIT 1");
    var_dump(  mysql_fetch_assoc($res) );
    $res = mysql_query("SELECT * FROM paymnt_details LIMIT 1");
    var_dump(  mysql_fetch_assoc($res) );
    $sql = "SELECT usr_details.* FROM usr_details LEFT JOIN paymnt_details ON usr_details.Trnsnubr = paymnt_details.Trnsnubr";
    $res = mysql_query($sql);
    var_dump($res);
    while($row=mysql_fetch_assoc($res)) {
        var_dump($row);
    }
    var_dump( mysql_error() );
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using EF 4.1 and a database I didn't design. I have two tables
I'm setting up a database using phpMyAdmin. I have two tables ( foo and
I am trying to import data from a large database. I have two tables
I am trying to join three tables together without any success so far. I
I have two tables in my database, Building and Town. They look like this:
This Codes give me error: Msg 156, Level 15, State 1, Procedure DefaultActivity, Line
This below codes give me error below: How to generate this codes help me
I'm using this codes for listing custom field values into drop-down list element on
i'm using the kendo ui grid on my backbone application. i used this codes.
What is the difference between this two codes? class SomeClass { SomeType val =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.