如果我使用where子句执行以下脚本而不是一行,它将返回无效或错误的值,如果我只为行值执行它,它会给出正确的结果..
<?php
include "database.php";
function getTotalLegL($memid,$leg)
{
$sql="select * from register where sid='".$memid."' and position='".$leg."'";
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
global $totala;
global $totalL;
$totala=$totala+mysql_num_rows($res);
if($row['regid']!='')
{
if($row['pack']=='Free'){
$tot=0;
}
if($row['pack']=='Silver'){
$tot=1;
}
if($row['pack']=='Gold'){
$tot=2;
}
getTotalLegL($row['regid'],'Var1');
getTotalLegL($row['regid'],'Var2');
$totalL+=$tot;
}
return $totalL;
}
function getTotalLegR($memid,$leg)
{
$sql="select * from register where sid='".$memid."' and position='".$leg."'";
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
global $totalR;
if($row['regid']!='')
{
if($row['pack']=='Free'){
$tot=0;
}
if($row['pack']=='Silver'){
$tot=1;
}
if($row['pack']=='Gold'){
$tot=2;
}
getTotalLegR($row['regid'],'Var1');
getTotalLegR($row['regid'],'Var2');
$totalR+=$tot;
}
return $totalR;
}
$sno=1;
$res=mysql_query("select * from register");
echo '<table>';
while($row=mysql_fetch_array($res)){
$mid=$row['regid'];
$lbv=getTotalLegL($mid,'Var1');
$rbv=getTotalLegR($mid,'Var2');
echo '<tr><td>'.$sno.'<td>'.$mid.'<td>'.$lbv.'<td>'.$rbv.'</td></tr>';
unset($lbv,$rbv);
$sno++;
}
echo '</table>';
?>
我不知道它为一个where子句值赋予正确值而不是多个值的原因...
getTotalLegL(),getTotalLegR()函数将收集$ mid的总下线信息。
所以如果我选择where子句只有值&amp;查询是$ res = mysql_query(&#34; select * from register limit 0,1&#34;);我会得到正确的价值...... 但是,如果我运行它liek $ res = mysql_query(&#34; select * from register limit 0,10&#34;); 我没有得到正确的价值,
请亲切地帮助我,拯救我的一天......
谢谢