代码正在将标头复制到每条记录

时间:2014-11-01 05:40:24

标签: php mysql

您好我有一个页面,它从MySQL的某些表中检索数据并将其显示为

用户但在此处while条件定义如上,因此将标题复制到每个

记录。

任何人都可以查看我的代码并告诉我问题在哪里吗?

以下是代码:

<?php
error_reporting(0);
  ob_start();
session_start();
if(!isset($_SESSION['email']))
{
  echo '<META HTTP-EQUIV="Refresh" Content="0; URL= ../../spd/myaccount.php">';
  exit();
}
else 
{
$email = $_SESSION['email'];
require_once('../../Admin Panel/db.php');

$query = "SELECT 
   properties.PropertyID,
   properties.PropertyType,
   properties.PropertyDealType,
   properties.Status,
   properties.PropostedPrice,
   properties.PropertyStatus,
   properties.RemoteEmployeeEmail,
   properties.PropertyDealerName,
   properties.PropertyOwnerName,
   remoteemployees.RemoteEmployeeID

   FROM remoteemployees,
        properties

   WHERE remoteemployees.RemoteEmployeeEmail = properties.RemoteEmployeeEmail   

   AND  properties.RemoteEmployeeEmail = '".$email."'

   AND  properties.Status= 'Active'

   AND  properties.PropertyStatus= 'APPROVED'


   ORDER BY properties.PropertyID
   ";


  $query_run = $connection->query($query);
  if( $connection->error ) exit( $connection->error );
  while($row=$query_run->fetch_assoc()) {
                $count      =   $queryrun->num_rows;          // Taking the number of queries returened by the result
                $array[]    =   $res;
         ?>


<html>
<head>
</head>
<body>
<div class="wrapper">
<div class="header">
<div style="float:left;"><font color="#000000">Welcome: <?php echo $_SESSION['email']; ?> 
</font>
</div>
<div style="float:right; color:#999; width:600px; margin-left:155px;">


<a href="#" style="  font: 15px verdana;
  text-decoration: none;
  background-color: #EEEEEE;
  color: #333333;
  padding: 2px 6px 2px 6px;
  border-top: 1px solid #CCCCCC;
  border-right: 1px solid #333333;
  border-bottom: 1px solid #333333;
  border-left: 1px solid #CCCCCC;
  cursor:pointer;">My Contract Copy</a>

<a href="#" style="  font: 15px verdana;
  text-decoration: none;
  background-color: #EEEEEE;
  color: #333333;
  padding: 2px 6px 2px 6px;
  border-top: 1px solid #CCCCCC;
  border-right: 1px solid #333333;
  border-bottom: 1px solid #333333;
  border-left: 1px solid #CCCCCC;
  cursor:pointer;">My Property List</a>

<a href="#" style="  font: 15px verdana;
  text-decoration: none;
  background-color: #EEEEEE;
  color: #333333;
  padding: 2px 6px 2px 6px;
  border-top: 1px solid #CCCCCC;
  border-right: 1px solid #333333;
  border-bottom: 1px solid #333333;
  border-left: 1px solid #CCCCCC;
  cursor:pointer;">My Trans.History</a>

<a href="Remote Employee profile.php?RemoteEmployeeid=<?php echo $row['RemoteEmployeeID'] ?>" style="  font: 15px verdana;
  text-decoration: none;
  background-color: #EEEEEE;
  color: #333333;
  padding: 2px 6px 2px 6px;
  border-top: 1px solid #CCCCCC;
  border-right: 1px solid #333333;
  border-bottom: 1px solid #333333;
  border-left: 1px solid #CCCCCC;
  cursor:pointer;">My Profile</a>

<a href="logout.php" style="  font: 15px verdana;
  text-decoration: none;
  background-color: #EEEEEE;
  color: #333333;
  padding: 2px 6px 2px 6px;
  border-top: 1px solid #CCCCCC;
  border-right: 1px solid #333333;
  border-bottom: 1px solid #333333;
  border-left: 1px solid #CCCCCC;
  cursor:pointer;">Logout</a>


</div>


</div>



<div class="Labelcon">
  <div class="Label">Property ID</div>
  <div class="Label">Property Type</div>
  <div class="Label">Property Deal Type</div>
  <div class="Labelowner">Property Owner</div>
  <div class="Labeldealer">Property Dealer</div>
  <div class="Label">Proposted Price</div>
  <div class="Label">Property Status</div>
</div>


<div class="Valuecon">
  <div class="Value"><?php echo $row['PropertyID'] ?></div>
  <div class="Value"><?php echo $row['PropertyType'] ?></div>
  <div class="Value"><?php echo $row['PropertyDealType']?></div>
  <div class="Valueowner"><?php echo $row['PropertyOwnerName'] ?></div>
  <div class="Valuedealer"><?php echo $row['PropertyDealerName'] ?></div>
  <div class="Value"><?php echo $row['PropostedPrice'];?></div>
  <div class="Value"><?php echo $row['PropertyStatus'];?></div>
</div>

<?php 
}}
?>
</div>
<p></p>
<center>
<?php $queryemail= "SELECT transactions.AmountPaid, transactions.TaxDeduction, transactions.AmountPayable from remoteemployees, transactions 

                    WHERE RemoteEmployeeEmail ='".$email."' limit 1"; ?>
<div class="Amountpayablepaid">

  <div class="amountpayable">

      <div class="aclabel">Amount Payable:</div>

      <div class="acvalue">

      <?php
       $queryemail_run = $connection->query($queryemail);
  if( $connection->error ) exit( $connection->error );
  while($row=$queryemail_run->fetch_assoc()) 
  {   
      ?>
      <div class="USD">
      <?php echo 'USD '.$row['AmountPayable'];  ?>
      </div>


      </div>
      <br>
    <br>  
  </div>
  <div class="amountpaid">

      <div class="acpaidlable">Tax Deduction:</div>

      <div class="acpaidvalue">

        <div class="USDpaid"><?php echo 'USD '.$row['TaxDeduction']; ?></div>


      </div>

  </div>

  <div class="amountpaid" style="margin-top:22px;">

      <div class="acpaidlable">Amount Paid:</div>

      <div class="acpaidvalue">

        <div class="USDpaid"><?php echo 'USD '.$row['AmountPaid'];}?></div>


      </div>

  </div>

</div>
</center>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

您可以在所有HTML上方启动while循环,但只需对表行<div class="Valuecon">执行此操作。所以把它移到正确的地方

也许这样的事情(我不是一个好的PHP编码器,所以它没有经过测试......但你应该明白这个想法):

{
  echo '<META HTTP-EQUIV="Refresh" Content="0; URL= ../../spd/myaccount.php">';
  exit();
}
else 
{
$email = $_SESSION['email'];
require_once('../../Admin Panel/db.php');

$query = "SELECT 
   properties.PropertyID,
   properties.PropertyType,
   properties.PropertyDealType,
   properties.Status,
   properties.PropostedPrice,
   properties.PropertyStatus,
   properties.RemoteEmployeeEmail,
   properties.PropertyDealerName,
   properties.PropertyOwnerName,
   remoteemployees.RemoteEmployeeID

   FROM remoteemployees,
        properties

   WHERE remoteemployees.RemoteEmployeeEmail = properties.RemoteEmployeeEmail   

   AND  properties.RemoteEmployeeEmail = '".$email."'

   AND  properties.Status= 'Active'

   AND  properties.PropertyStatus= 'APPROVED'


   ORDER BY properties.PropertyID
   ";


         ?>


<html>
<head>
<style>
.wrapper
{
  width:1250px;
  height:auto;
  border:solid 1px #ccc;
  margin:0 auto;
  padding:5px 5px 5px 5px;
  border-radius:5px;
  -webkit-border-radius:5px;
  -moz-border-radius:5px;
  -ms-border-radius:5px;
  font-family:"Arial";
}
.wrapper .header
{
  width:1250px;
  height:30px;
  border-bottom:solid 1px #f0eeee;
  margin:auto 0;
  margin-bottom:12px;
}
.wrapper .header div
{
text-decoration:none;
color:#000;
}
.wrapper .header div a
{
text-decoration:none;
color:#000;
}
.wrapper .Labelcon
{
  width:1250px;
  height:29px;
}

.wrapper .Labelcon .Label
{
  width:135px;
  height:20px;
  float:left;
  text-align:center;
  border-left:1px solid #f0eeee;
  font:Verdana, Geneva, sans-serif;
  font-size:14.3px;
  font-weight:bold;

}

.wrapper .Labelcon .Labelowner
{
  width:150px;
  height:20px;
  float:left;
  text-align:center;
  border-left:1px solid #f0eeee;
  font:Verdana, Geneva, sans-serif;
  font-size:14.3px;
  font-weight:bold;

}

.wrapper .Labelcon .Labeldealer
{
  width:150px;
  height:20px;
  float:left;
  text-align:center;
  border-left:1px solid #f0eeee;
  font:Verdana, Geneva, sans-serif;
  font-size:14.3px;
  font-weight:bold;

}

.wrapper .Valuecon
{
  width:1250px;
  height:29px;
  border-top:solid 1px #ccc;
  color:#000;
  text-decoration:none;
}
.wrapper .Valuecon .Value
{
  width:135px;
  height:20px;
  float:left;
  text-align:center;
  border-left:1px solid #f0eeee;
  font-size:14px;
}
.wrapper .Valuecon .Valueowner
{
  width:150px;
  height:20px;
  float:left;
  text-align:center;
  border-left:1px solid #f0eeee;
  font-size:14px;
}

.wrapper .Valuecon .Valuedealer
{
  width:150px;
  height:20px;
  float:left;
  text-align:center;
  border-left:1px solid #f0eeee;
  font-size:14px;
}

.Amountpayablepaid
{
    margin:0 auto;
    width:375px;
    height:120px;
    font-family:"Arial";
    padding:8px;
    border:solid 1px #ccc;
    border-radius:6px;
    -moz-border-radius:6px;
    -webkit-border-radius:6px;
    -ms-border-radius:6px;
}
.Amountpayablepaid .amountpayable
{
    width:600px;
    height:30px;
  color:#000;
  text-decoration:none;
}

.Amountpayablepaid .amountpayable .aclabel
{
    width:145px;
    line-height: 30px;
    height:30px;
    border:solid 1px #ccc;
    float:left;
}
.Amountpayablepaid .amountpayable .acvalue
{
    width:445px;
    height:30px;
    float:right;
    line-height: 30px;
}

.Amountpayablepaid .amountpayable .acvalue .USD
{
    width:218px;
    height:30px;
    border:solid 1px #ccc;
    float:left;
}

.Amountpayablepaid .amountpayable .acvalue .AFN
{
    width:218px;
    height:30px;
    border:solid 1px #ccc;
    float:right;
}
.Amountpayablepaid .amountpaid
{
    width:600px;
    height:30px;
  color:#000;
  text-decoration:none;
  float:left;
}

.Amountpayablepaid .amountpaid .acpaidlable
{
    width:145px;
    height:30px;
    border:solid 1px #ccc;
    float:left;
    line-height: 30px;
}
.Amountpayablepaid .amountpaid .acpaidvalue
{
    width:445px;
    height:30px;
    float:right;
}
.Amountpayablepaid .amountpaid .acpaidvalue .USDpaid
{
    width:218px;
    height:30px;
    border:solid 1px #ccc;
    float:left;
    line-height: 30px;
}

.Amountpayablepaid .amountpaid .acpaidvalue .AFNpaid
{
    width:218px;
    height:30px;
    border:solid 1px #ccc;
    float:right;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="header">
<div style="float:left;"><font color="#000000">Welcome: <?php echo $_SESSION['email']; ?> 
</font>
</div>
<div style="float:right; color:#999; width:600px; margin-left:155px;">


<a href="#" style="  font: 15px verdana;
  text-decoration: none;
  background-color: #EEEEEE;
  color: #333333;
  padding: 2px 6px 2px 6px;
  border-top: 1px solid #CCCCCC;
  border-right: 1px solid #333333;
  border-bottom: 1px solid #333333;
  border-left: 1px solid #CCCCCC;
  cursor:pointer;">My Contract Copy</a>

<a href="#" style="  font: 15px verdana;
  text-decoration: none;
  background-color: #EEEEEE;
  color: #333333;
  padding: 2px 6px 2px 6px;
  border-top: 1px solid #CCCCCC;
  border-right: 1px solid #333333;
  border-bottom: 1px solid #333333;
  border-left: 1px solid #CCCCCC;
  cursor:pointer;">My Property List</a>

<a href="#" style="  font: 15px verdana;
  text-decoration: none;
  background-color: #EEEEEE;
  color: #333333;
  padding: 2px 6px 2px 6px;
  border-top: 1px solid #CCCCCC;
  border-right: 1px solid #333333;
  border-bottom: 1px solid #333333;
  border-left: 1px solid #CCCCCC;
  cursor:pointer;">My Trans.History</a>

<a href="Remote Employee profile.php?RemoteEmployeeid=<?php echo $row['RemoteEmployeeID'] ?>" style="  font: 15px verdana;
  text-decoration: none;
  background-color: #EEEEEE;
  color: #333333;
  padding: 2px 6px 2px 6px;
  border-top: 1px solid #CCCCCC;
  border-right: 1px solid #333333;
  border-bottom: 1px solid #333333;
  border-left: 1px solid #CCCCCC;
  cursor:pointer;">My Profile</a>

<a href="logout.php" style="  font: 15px verdana;
  text-decoration: none;
  background-color: #EEEEEE;
  color: #333333;
  padding: 2px 6px 2px 6px;
  border-top: 1px solid #CCCCCC;
  border-right: 1px solid #333333;
  border-bottom: 1px solid #333333;
  border-left: 1px solid #CCCCCC;
  cursor:pointer;">Logout</a>


</div>


</div>



<div class="Labelcon">
  <div class="Label">Property ID</div>
  <div class="Label">Property Type</div>
  <div class="Label">Property Deal Type</div>
  <div class="Labelowner">Property Owner</div>
  <div class="Labeldealer">Property Dealer</div>
  <div class="Label">Proposted Price</div>
  <div class="Label">Property Status</div>
</div>
<php


  $query_run = $connection->query($query);
  if( $connection->error ) exit( $connection->error );
  while($row=$query_run->fetch_assoc()) {
                $count      =   $queryrun->num_rows;          // Taking the number of queries returened by the result
                $array[]    =   $res; 
  ?>

<div class="Valuecon">
  <div class="Value"><?php echo $row['PropertyID'] ?></div>
  <div class="Value"><?php echo $row['PropertyType'] ?></div>
  <div class="Value"><?php echo $row['PropertyDealType']?></div>
  <div class="Valueowner"><?php echo $row['PropertyOwnerName'] ?></div>
  <div class="Valuedealer"><?php echo $row['PropertyDealerName'] ?></div>
  <div class="Value"><?php echo $row['PropostedPrice'];?></div>
  <div class="Value"><?php echo $row['PropertyStatus'];?></div>
</div>

<?php 
}}
?>
</div>
<p></p>
<center>
<?php $queryemail= "SELECT transactions.AmountPaid, transactions.TaxDeduction, transactions.AmountPayable from remoteemployees, transactions 

                    WHERE RemoteEmployeeEmail ='".$email."' limit 1"; ?>
<div class="Amountpayablepaid">

  <div class="amountpayable">

      <div class="aclabel">Amount Payable:</div>

      <div class="acvalue">

      <?php
       $queryemail_run = $connection->query($queryemail);
  if( $connection->error ) exit( $connection->error );
  while($row=$queryemail_run->fetch_assoc()) 
  {   
      ?>
      <div class="USD">
      <?php echo 'USD '.$row['AmountPayable'];  ?>
      </div>


      </div>
      <br>
    <br>  
  </div>
  <div class="amountpaid">

      <div class="acpaidlable">Tax Deduction:</div>

      <div class="acpaidvalue">

        <div class="USDpaid"><?php echo 'USD '.$row['TaxDeduction']; ?></div>


      </div>

  </div>

  <div class="amountpaid" style="margin-top:22px;">

      <div class="acpaidlable">Amount Paid:</div>

      <div class="acpaidvalue">

        <div class="USDpaid"><?php echo 'USD '.$row['AmountPaid'];}?></div>


      </div>

  </div>

</div>
</center>
</body>
</html>