Php 如何在while循环查询中包含字段?
我在查询中使用了<代码>前缀<代码>,但是在页面的中间,我有一个字段<代码> $ROC[$ReaTeMeMeID ID ] 这是OFF while循环,我不能把它包含在while循环中,如果我包含它,那么我的页眉将被记录在每个记录中。 这是我的密码:Php 如何在while循环查询中包含字段?,php,mysql,Php,Mysql,我在查询中使用了前缀,但是在页面的中间,我有一个字段 $ROC[$ReaTeMeMeID ID ] 这是OFF while循环,我不能把它包含在while循环中,如果我包含它,那么我的页眉将被记录在每个记录中。 这是我的密码: <html> <head> </head> <body> <div class="wrapper"> <div class="header"> <?php error_reporting('0'
<html>
<head>
</head>
<body>
<div class="wrapper">
<div class="header">
<?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($res=$query_run->fetch_assoc()) {
$count = $query_run->num_rows; // Taking the number of queries returened by the result
$array[] = $res;
}
?>
<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="#" class="button">My Contract Copy</a>
<a href="#" class="button">My Property List</a>
<a href="#" class="button">My Trans.History</a>
<a href="Remote Employee profile.php?RemoteEmployeeid=<?php echo $row['RemoteEmployeeID'] ?>" class="button" >My Profile</a>
<a href="logout.php" class="button">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
// Here is the start of the loop
foreach($array as $row) { ?>
<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
if($query_run->num_rows == 0)
{
echo 'No Records Found';
}
}}
?>
</div>
<p></p>
<center>
<?php $queryemail= "SELECT SUM(transactions.EarnAmount) AS TotalEarn, transactions.TaxDeduction,
SUM(transactions.AmountPaid) AS TotalPaid from transactions WHERE transactions.RemoteEmployeeID = ".$row['RemoteEmployeeID']." limit 1"; ?>
<div class="Amountpayablepaid">
<div class="amountpayable">
<div class="aclabel">Earn Amount:</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['TotalEarn']; ?>
</div>
</div>
<br>
<br>
</div>
<div class="amountpaid">
<div class="acpaidlable">Tax Deduction:</div>
<div class="acpaidvalue">
<div class="USDpaid"><?php echo $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['TotalPaid'];}?></div>
</div>
</div>
</div>
</center>
</body>
</html>
属性ID
属性类型
物业交易类型
业主
地产商
建议价格
财产状况
赚取金额:
扣税:
支付金额:
它很简单:
$RemoteEmp = null;
$count = $query_run->num_rows;
while($res=$query_run->fetch_assoc()) {
$array[] = $res;
$RemoteEmp = $res["RemoteEmployeeID"];
}
现在:
<a href="Remote Employee profile.php?RemoteEmployeeid=<?php echo $RemoteEmp; ?>" class="button" >My Profile</a>
老实说,我认为您显示的代码太多了。你应该只显示必要的内容。谢谢,当我需要其他菜单时,它起作用了,所以我应该只更改中的RemoteEmployeeIDarray@Priyabapat,mysql
与PHP5.5.0一样被弃用,因此如果您的PHP5.5.0版本将来发生更改,那么您的整个脚本将停止运行。做一个聪明的程序员,开始使用mysqli_uuuuuuu或PDO
有没有办法自动转换?没有办法,你必须手动更改脚本。但是,是的,最好的选择是使用PDO,它将为您提供在PHP支持的数据库上单行移动的独立性。您所说的在PHP支持的数据库上单行移动的独立性是什么意思